Merge pull request #63 from gansm/master

Merge
This commit is contained in:
Markus Gans 2020-09-17 02:08:15 +02:00 committed by GitHub
commit 8784a4c925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
224 changed files with 8599 additions and 4340 deletions

2
.gitignore vendored
View File

@ -32,12 +32,14 @@ Makefile.in
/missing /missing
/stamp-h1 /stamp-h1
/test-driver /test-driver
src/.depend
src/.deps/ src/.deps/
src/.libs/ src/.libs/
examples/.deps/ examples/.deps/
examples/.libs/ examples/.libs/
examples/calculator examples/calculator
examples/dialog examples/dialog
examples/busy
examples/event-log examples/event-log
examples/string-operations examples/string-operations
examples/background-color examples/background-color

View File

@ -1,3 +1,48 @@
2020-09-11 Markus Gans <guru.mail@muenster.de>
* Fixes a problem with mouse input in Cygwin in non-blocking read mode
2020-09-08 Markus Gans <guru.mail@muenster.de>
* Speed up the reaction time of the gpm mouse
* FListView now correctly adjusts the size of the scrollbar,
when expanding and collapsing by double-clicking
2020-08-30 Markus Gans <guru.mail@muenster.de>
* Adding Windows Terminal detection
2020-08-15 Markus Gans <guru.mail@muenster.de>
* The call of the function setNonBlockingRead() resulted in
a high CPU load in idle mode.
Thanks to Pavel Stehule for reporting this problem.
2020-08-11 Markus Gans <guru.mail@muenster.de>
* New callback backend was implemented. Callback functions with any
number of arguments are now possible.
2020-07-19 Markus Gans <guru.mail@muenster.de>
* API: Some method name changes:
FObject::delOwnTimer() -> FObject::delOwnTimers()
FObject::delAllTimer() -> FObject::delAllTimers()
FWidget::delCallbacks() -> FWidget::delAllCallbacks()
2020-07-08 Markus Gans <guru.mail@muenster.de>
* New data wrapper class FData
2020-07-06 Markus Gans <guru.mail@muenster.de>
* Add a document that describes how to create user themes
2020-06-11 Markus Gans <guru.mail@muenster.de>
* New widget FBusyIndicator to indicate background activity
* Added example/busy to demonstrate the functionality of this widget
2020-06-07 Markus Gans <guru.mail@muenster.de>
* The --log-file parameter stores log output to any file. The file
can be viewed directly on another terminal with "tail -f".
2020-06-06 Markus Gans <guru.mail@muenster.de>
* Now, the terminal is not initialized before the method show()
is called. Or you force it explicitly via the FApplication object.
* Simplification of FMouse::createMouseObject()
2020-05-30 Markus Gans <guru.mail@muenster.de> 2020-05-30 Markus Gans <guru.mail@muenster.de>
* With the two new methods FApplication::setDarkTheme() and * With the two new methods FApplication::setDarkTheme() and
FApplication::setDefaultTheme() you can now change the theme FApplication::setDefaultTheme() you can now change the theme

View File

@ -19,3 +19,7 @@ docdir = ${datadir}/doc/${PACKAGE}
doc_DATA = AUTHORS COPYING COPYING.LESSER ChangeLog doc_DATA = AUTHORS COPYING COPYING.LESSER ChangeLog
test: check test: check
uninstall-hook:
if test -d ${docdir}; then rmdir ${docdir}; fi

View File

@ -1,11 +1,13 @@
![FINAL CUT](logo/svg/finalcut-logo.svg) ![FINAL CUT](logo/svg/finalcut-logo.svg)
# Library for creating terminal applications with text-based widgets # Library for creating terminal applications with text-based widgets
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
The FINAL CUT is a C++ class library and widget toolkit with full [mouse](doc/mouse-control.md#title-bar-actions-on-mouse-clicks) support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on. The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
## Building and code analysis ## Building and code analysis
| | Badge | | | Badge |
|-------------------:|:------| |-------------------:|:------|
| *Latest release* | [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) | | *Latest release* | [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) |
@ -18,6 +20,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
| *CodeFactor* | [![CodeFactor](https://www.codefactor.io/repository/github/gansm/finalcut/badge)](https://www.codefactor.io/repository/github/gansm/finalcut) | | *CodeFactor* | [![CodeFactor](https://www.codefactor.io/repository/github/gansm/finalcut/badge)](https://www.codefactor.io/repository/github/gansm/finalcut) |
## Installation ## Installation
```bash ```bash
> git clone git://github.com/gansm/finalcut.git > git clone git://github.com/gansm/finalcut.git
> cd finalcut > cd finalcut
@ -28,6 +31,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
``` ```
## Supported platforms ## Supported platforms
* Linux * Linux
* FreeBSD * FreeBSD
* NetBSD * NetBSD
@ -37,6 +41,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
* Solaris * Solaris
## First steps ## First steps
See the [first steps](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit) documentation for information on how to use the library. See the [first steps](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit) documentation for information on how to use the library.
## Some screenshots ## Some screenshots
@ -45,46 +50,38 @@ The FFileDialog widget with incremental file name search:
![FFileDialog](doc/fileopen-dialog.png) ![FFileDialog](doc/fileopen-dialog.png)
The FINAL CUT FProgressbar widget: The FINAL CUT FProgressbar widget:
![FProgressbar](doc/progress-bar.png) ![FProgressbar](doc/progress-bar.png)
Scrollable text in the FTextView widget: Scrollable text in the FTextView widget:
![FTextView](doc/textview.png) ![FTextView](doc/textview.png)
The Mandelbrot set example: The Mandelbrot set example:
![Mandelbrot set](doc/Mandelbrot.png) ![Mandelbrot set](doc/Mandelbrot.png)
## newfont
newfont
-------
A [graphical text font](fonts/) for X11 and the Linux console. A [graphical text font](fonts/) for X11 and the Linux console.
![ui example in newfont mode](doc/newfont1.png) ![ui example in newfont mode](doc/newfont1.png)
Newfont drive symbols: Newfont drive symbols:
![drive symbols](doc/newfont2.png) ![drive symbols](doc/newfont2.png)
The calculator example in newfont mode: The calculator example in newfont mode:
![calculator](doc/calculator.png) ![calculator](doc/calculator.png)
## Benchmark
Benchmark
---------
Here you can find a test for [measuring the character speed](doc/benchmark.md#benchmark) in the terminal. Here you can find a test for [measuring the character speed](doc/benchmark.md#benchmark) in the terminal.
## Virtual terminal
Virtual terminal
----------------
FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen. FINAL CUT uses a virtual terminal to print character via an update method on the screen. It provides (as an overlying layer) virtual windows for the realization of window movements. The update methods only transfer differences to the virtual terminal or physical screen.
<pre style="line-height: 1 !important;"> <pre style="line-height: 1 !important;">
@ -136,9 +133,7 @@ printf(...)
▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀
</pre> </pre>
## Class digramm
Class digramm
-------------
<pre style="line-height: 1 !important;"> <pre style="line-height: 1 !important;">
1┌──────────────┐ 1┌──────────────┐
@ -177,11 +172,11 @@ Class digramm
: 1┌───────────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌─────────┐ │ : 1┌─────────┐ │ ┌──────┐ ┌─────────┐
┌-----------┤ FSystem │ │ ┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │
: └─────────┘ │ : └─────────┘ │ └──┬───┘ └─────────┘
: *┌─────────┐ │ : *┌─────────┐ │ :1
: ┌--------┤ FString │ │ ┌─────────────┐ : ┌--------┤ FString │ │ ┌─────────────┐
: : └─────────┘ │ ┌────┤ FApplication │ : : └─────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └──────────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌────────┐
@ -201,11 +196,11 @@ Class digramm
│ FVTerm │◄──┐ :1 │ └──────────────┘ │ └──────────────┘ │ FVTerm │◄──┐ :1 │ └──────────────┘ │ └──────────────┘
└────────┘ │ ┌────┴────┐ │ ┌───────────────┐ │ ┌───────────┐ └────────┘ │ ┌────┴────┐ │ ┌───────────────┐ │ ┌───────────┐
├────┤ FWidget │◄───────┼────┤ FToggleButton │◄─┼──┤ FCheckBox │ ├────┤ FWidget │◄───────┼────┤ FToggleButton │◄─┼──┤ FCheckBox │
┌─────────┐ │ └────────┘ │ └───────────────┘ │ └───────────┘ ┌─────────┐ │ └────────┘ │ └───────────────┘ │ └───────────┘
│ FObject │◄──┘ │ ┌──────────────┐ │ ┌─────────┐ │ FObject │◄──┘ :1 │ ┌──────────────┐ │ ┌─────────┐
└─────────┘ ├────┤ FProgressbar │ └──┤ FSwitch │ └─────────┘ ┌──────┴────────┐ ├────┤ FProgressbar │ └──┤ FSwitch │
│ └──────────────┘ └─────────┘ │ FWidgetColors │ │ └──────────────┘ └─────────┘
│ ┌────────────┐ └───────────────┘ │ ┌────────────┐
├────┤ FScrollbar │ ├────┤ FScrollbar │
│ └────────────┘ │ └────────────┘
│ ┌───────────┐ │ ┌───────────┐
@ -233,9 +228,9 @@ Class digramm
└──┬──┬───┘ └─────────┘ │ ┌─────────────┐ └──┬──┬───┘ └─────────┘ │ ┌─────────────┐
▲ ▲ └──┤ FMessageBox │ ▲ ▲ └──┤ FMessageBox │
│ │ └─────────────┘ │ │ └─────────────┘
│ │ ┌──────────┐ │ │ ┌──────────┐ ┌────────────────┐
│ └──────┤ FToolTip │ │ └──────┤ FToolTip │◄─┤ FBusyIndicator │
│ └──────────┘ │ └──────────┘ └────────────────┘
└───────────────┐ ┌──────────┐ └───────────────┐ ┌──────────┐
│ ┌───┤ FMenuBar │ │ ┌───┤ FMenuBar │
┌───────────┐ └──────┤ └──────────┘ ┌───────────┐ └──────┤ └──────────┘
@ -254,15 +249,14 @@ Class digramm
└────────────────┘ └────────────────┘
</pre> </pre>
Frequently Asked Questions ## Frequently Asked Questions
--------------------------
For general questions about FINAL CUT, likely the answer is already included in the [FAQ](doc/faq.md#frequently-asked-questions). For general questions about FINAL CUT, likely the answer is already included in the [FAQ](doc/faq.md#frequently-asked-questions).
Please send bug reports to ## Please send bug reports to
--------------------------
https://github.com/gansm/finalcut/issues https://github.com/gansm/finalcut/issues
License ## License
-------
GNU Lesser General Public License Version 3 <a href="https://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img width="200" align="right" src="https://camo.githubusercontent.com/726b87cc2ebaf8c40716842ff509c5f874381c8e/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f332f33622f4c47504c76335f4c6f676f2e737667" alt="LGPLv3" data-canonical-src="https://upload.wikimedia.org/wikipedia/commons/3/3b/LGPLv3_Logo.svg"></a>
GNU Lesser General Public License Version 3 <a href="https://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img width="200" align="right" src="https://camo.githubusercontent.com/726b87cc2ebaf8c40716842ff509c5f874381c8e/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f332f33622f4c47504c76335f4c6f676f2e737667" alt="LGPLv3" data-canonical-src="https://upload.wikimedia.org/wikipedia/commons/3/3b/LGPLv3_Logo.svg"></a>

View File

@ -86,12 +86,12 @@ AX_CHECK_COMPILE_FLAG([[-std=c++11]],,
# use GPM (General Purpose Mouse) # use GPM (General Purpose Mouse)
AC_ARG_WITH([gpm], AC_ARG_WITH([gpm],
[AS_HELP_STRING([--without-gpm], [Disable GPM mouse support])], [AS_HELP_STRING([--without-gpm], [Disable GPM mouse support])],
[with_gpm=no], [],
[with_gpm=yes]) [with_gpm=yes])
if test "x$with_gpm" = "xyes" if test "x$with_gpm" != "xno"
then then
AC_CHECK_LIB([gpm], AC_CHECK_LIB([gpm],
[main], [Gpm_Open],
[AC_DEFINE([HAVE_LIBGPM], 1, [Define to 1 if GPM mouse is enabled]) [AC_DEFINE([HAVE_LIBGPM], 1, [Define to 1 if GPM mouse is enabled])
LIBS="$LIBS -lgpm"]) LIBS="$LIBS -lgpm"])
fi fi
@ -99,9 +99,9 @@ fi
# profiling # profiling
AC_ARG_WITH([profiler], AC_ARG_WITH([profiler],
[AS_HELP_STRING([--with-profiler], [build extra google profiler binaries])], [AS_HELP_STRING([--with-profiler], [build extra google profiler binaries])],
[with_profiler=yes], [],
[with_profiler=no]) [with_profiler=no])
if test "x$with_profiler" = "xyes" if test "x$with_profiler" != "xno"
then then
AC_CHECK_LIB([profiler], AC_CHECK_LIB([profiler],
[ProfilerFlush], [ProfilerFlush],
@ -111,14 +111,13 @@ fi
# unit test # unit test
AC_ARG_WITH([unit-test], AC_ARG_WITH([unit-test],
[AS_HELP_STRING([--with-unit-test], [build unit tests])], [AS_HELP_STRING([--with-unit-test], [build unit tests])],
[with_unit_test=yes], [],
[with_unit_test=no]) [with_unit_test=no])
if test "x$with_unit_test" = "xyes" if test "x$with_unit_test" != "xno"
then then
AC_MSG_NOTICE(enabled cppunit test) AC_MSG_NOTICE(enabled cppunit test)
AM_PATH_CPPUNIT([1.12.0], PKG_CHECK_MODULES(CPPUNIT,
[], [cppunit > 1.12.0])
[AC_MSG_ERROR([*** CppUnit not found! ***])])
AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "1"]) AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "1"])
else else
AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"]) AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"])
@ -128,9 +127,9 @@ fi
# code coverage # code coverage
AC_ARG_WITH([gcov], AC_ARG_WITH([gcov],
[AS_HELP_STRING([--with-gcov], [build for code coverage testing])], [AS_HELP_STRING([--with-gcov], [build for code coverage testing])],
[with_gcov=yes], [],
[with_gcov=no]) [with_gcov=no])
if test "x$with_gcov" = "xyes" if test "x$with_gcov" != "xno"
then then
AC_CHECK_LIB([gcov], AC_CHECK_LIB([gcov],
[main], [main],

6
debian/control vendored
View File

@ -27,7 +27,7 @@ Suggests:
, ncurses-term , ncurses-term
, vim-common , vim-common
Description: Shared library for the final cut widget toolkit Description: Shared library for the final cut widget toolkit
The Final Cut is a class library and widget toolkit with full mouse FINAL CUT is a class library and widget toolkit with full mouse
support for creating a text-based user interface. The library supports support for creating a text-based user interface. The library supports
the programmer to develop an application for the text console. It allows the programmer to develop an application for the text console. It allows
the simultaneous handling of multiple windows on the screen. the simultaneous handling of multiple windows on the screen.
@ -50,7 +50,7 @@ Depends:
, libtinfo-dev , libtinfo-dev
, libncurses5-dev , libncurses5-dev
Description: Developer's library for the final cut widget toolkit Description: Developer's library for the final cut widget toolkit
The Final Cut is a class library and widget toolkit with full mouse FINAL CUT is a class library and widget toolkit with full mouse
support for creating a text-based user interface. The library supports support for creating a text-based user interface. The library supports
the programmer to develop an application for the text console. It allows the programmer to develop an application for the text console. It allows
the simultaneous handling of multiple windows on the screen. the simultaneous handling of multiple windows on the screen.
@ -74,7 +74,7 @@ Depends:
, libtinfo-dev , libtinfo-dev
, libncurses5-dev , libncurses5-dev
Description: Test and example programs for the final cut widget toolkit Description: Test and example programs for the final cut widget toolkit
The Final Cut is a class library and widget toolkit with full mouse FINAL CUT is a class library and widget toolkit with full mouse
support for creating a text-based user interface. The library supports support for creating a text-based user interface. The library supports
the programmer to develop an application for the text console. It allows the programmer to develop an application for the text console. It allows
the simultaneous handling of multiple windows on the screen. the simultaneous handling of multiple windows on the screen.

6
debian/copyright vendored
View File

@ -7,13 +7,13 @@ Copyright: 2017, Markus Gans <guru.mail@muenster.de>
License: LGPL-3 License: LGPL-3
License: LGPL-3 License: LGPL-3
The Final Cut is free software: you can redistribute it and/or modify FINAL CUT is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
. .
The Final Cut is distributed in the hope that it will be useful, FINAL CUT is distributed in the hope that it will be useful, but
but WITHOUT ANY WARRANTY; without even the implied warranty of WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details. GNU Lesser General Public License for more details.
. .

View File

@ -5,6 +5,7 @@
docdir = ${datadir}/doc/${PACKAGE} docdir = ${datadir}/doc/${PACKAGE}
EXTRA_DIST = \ EXTRA_DIST = \
benchmark.md \
build_openbsd.txt \ build_openbsd.txt \
build_solaris.txt \ build_solaris.txt \
calendar-draft.png \ calendar-draft.png \
@ -16,9 +17,21 @@ EXTRA_DIST = \
console_ioctl-manual.sh \ console_ioctl-manual.sh \
faq.md \ faq.md \
fileopen-dialog.png \ fileopen-dialog.png \
final-cut-application-structure.svg \
first-steps.md \ first-steps.md \
first-steps_callback-function.cpp.png \
first-steps_callback-lambda.cpp.png \
first-steps_callback-method.cpp.png \
first-steps_dialog.cpp.png \
first-steps_emit-signal.cpp.png \
first-steps_memory.cpp.png \
first-steps_scrollview.cpp.png \
first-steps_size-adjustment.cpp.png \
first-steps_timer.cpp.png \
first-steps_user-event.cpp.png \
framebuffer.txt \ framebuffer.txt \
Mandelbrot.png \ Mandelbrot.png \
mouse-control.md \
ncurses.supp \ ncurses.supp \
newfont1.png \ newfont1.png \
newfont2.png \ newfont2.png \
@ -31,13 +44,24 @@ EXTRA_DIST = \
terminfo-manual.sh \ terminfo-manual.sh \
textview.png \ textview.png \
TODO \ TODO \
user-theme.md \
user-theme.png \
user-theme-bee-palette.svg \
user-theme-fc16-dark-palette.svg \
user-theme-fc16-palette.svg \
user-theme-fc8-palette.svg \
user-theme-vga-palette.svg \
vga.txt \ vga.txt \
vt100_line_drawing_graphics.png \ vt100_line_drawing_graphics.png \
virtual-terminal.txt \ virtual-terminal.txt \
widget-coordinates.svg \
widget-geometry.svg \
widget-lengths.svg \
xterm.txt \ xterm.txt \
xgraphics xgraphics
doc_DATA = \ doc_DATA = \
benchmark.md \
build_openbsd.txt \ build_openbsd.txt \
build_solaris.txt \ build_solaris.txt \
calendar-draft.png \ calendar-draft.png \
@ -49,9 +73,21 @@ doc_DATA = \
console_ioctl-manual.sh \ console_ioctl-manual.sh \
faq.md \ faq.md \
fileopen-dialog.png \ fileopen-dialog.png \
final-cut-application-structure.svg \
first-steps.md \ first-steps.md \
first-steps_callback-function.cpp.png \
first-steps_callback-lambda.cpp.png \
first-steps_callback-method.cpp.png \
first-steps_dialog.cpp.png \
first-steps_emit-signal.cpp.png \
first-steps_memory.cpp.png \
first-steps_scrollview.cpp.png \
first-steps_size-adjustment.cpp.png \
first-steps_timer.cpp.png \
first-steps_user-event.cpp.png \
framebuffer.txt \ framebuffer.txt \
Mandelbrot.png \ Mandelbrot.png \
mouse-control.md \
ncurses.supp \ ncurses.supp \
newfont1.png \ newfont1.png \
newfont2.png \ newfont2.png \
@ -64,8 +100,19 @@ doc_DATA = \
terminfo-manual.sh \ terminfo-manual.sh \
textview.png \ textview.png \
TODO \ TODO \
user-theme.md \
user-theme.png \
user-theme-bee-palette.svg \
user-theme-fc16-dark-palette.svg \
user-theme-fc16-palette.svg \
user-theme-fc8-palette.svg \
user-theme-vga-palette.svg \
vga.txt \ vga.txt \
vt100_line_drawing_graphics.png \ vt100_line_drawing_graphics.png \
virtual-terminal.txt \ virtual-terminal.txt \
widget-coordinates.svg \
widget-geometry.svg \
widget-lengths.svg \
xterm.txt \ xterm.txt \
xgraphics xgraphics

View File

@ -37,11 +37,11 @@
: 1┌───────────────┐ │ ┌─────────────┐ : 1┌───────────────┐ │ ┌─────────────┐
┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │
: └───────────────┘ │ └─────────────┘ : └───────────────┘ │ └─────────────┘
: 1┌─────────┐ │ : 1┌─────────┐ │ ┌──────┐ ┌─────────┐
┌-----------┤ FSystem │ │ ┌-----------┤ FSystem │ │ │ FLog │◄──┤ FLogger │
: └─────────┘ │ : └─────────┘ │ └──┬───┘ └─────────┘
: *┌─────────┐ │ : *┌─────────┐ │ :1
: ┌--------┤ FString │ │ ┌─────────────┐ : ┌--------┤ FString │ │ ┌─────────────┐
: : └─────────┘ │ ┌────┤ FApplication │ : : └─────────┘ │ ┌────┤ FApplication │
: : *┌────────┐ │ │ └──────────────┘ : : *┌────────┐ │ │ └──────────────┘
: ┌--------┤ FPoint │ │ │ ┌────────┐ : ┌--------┤ FPoint │ │ │ ┌────────┐
@ -61,11 +61,11 @@
│ FVTerm │◄──┐ :1 │ └──────────────┘ │ └──────────────┘ │ FVTerm │◄──┐ :1 │ └──────────────┘ │ └──────────────┘
└────────┘ │ ┌────┴────┐ │ ┌───────────────┐ │ ┌───────────┐ └────────┘ │ ┌────┴────┐ │ ┌───────────────┐ │ ┌───────────┐
├────┤ FWidget │◄───────┼────┤ FToggleButton │◄─┼──┤ FCheckBox │ ├────┤ FWidget │◄───────┼────┤ FToggleButton │◄─┼──┤ FCheckBox │
┌─────────┐ │ └────────┘ │ └───────────────┘ │ └───────────┘ ┌─────────┐ │ └────────┘ │ └───────────────┘ │ └───────────┘
│ FObject │◄──┘ │ ┌──────────────┐ │ ┌─────────┐ │ FObject │◄──┘ :1 │ ┌──────────────┐ │ ┌─────────┐
└─────────┘ ├────┤ FProgressbar │ └──┤ FSwitch │ └─────────┘ ┌──────┴────────┐ ├────┤ FProgressbar │ └──┤ FSwitch │
│ └──────────────┘ └─────────┘ │ FWidgetColors │ │ └──────────────┘ └─────────┘
│ ┌────────────┐ └───────────────┘ │ ┌────────────┐
├────┤ FScrollbar │ ├────┤ FScrollbar │
│ └────────────┘ │ └────────────┘
│ ┌───────────┐ │ ┌───────────┐
@ -93,9 +93,9 @@
└──┬──┬───┘ └─────────┘ │ ┌─────────────┐ └──┬──┬───┘ └─────────┘ │ ┌─────────────┐
▲ ▲ └──┤ FMessageBox │ ▲ ▲ └──┤ FMessageBox │
│ │ └─────────────┘ │ │ └─────────────┘
│ │ ┌──────────┐ │ │ ┌──────────┐ ┌────────────────┐
│ └──────┤ FToolTip │ │ └──────┤ FToolTip │◄─┤ FBusyIndicator │
│ └──────────┘ │ └──────────┘ └────────────────┘
└───────────────┐ ┌──────────┐ └───────────────┐ ┌──────────┐
│ ┌───┤ FMenuBar │ │ ┌───┤ FMenuBar │
┌───────────┐ └──────┤ └──────────┘ ┌───────────┐ └──────┤ └──────────┘

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fclassname.cpp - [brief description] * * fclassname.cpp - [brief description] *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright [year] [Maintainer] * * Copyright [year] [Maintainer] *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fclassname.h - [brief description] * * fclassname.h - [brief description] *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright [year] [Maintainer] * * Copyright [year] [Maintainer] *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -126,4 +126,3 @@ class FClassName
#endif // FCLASSNAME_H #endif // FCLASSNAME_H

View File

@ -6,7 +6,7 @@ Frequently Asked Questions
What is FINAL CUT? What is FINAL CUT?
------------------ ------------------
The FINAL CUT is a [C++](https://en.wikipedia.org/wiki/C%2B%2B) class library FINAL CUT is a [C++](https://en.wikipedia.org/wiki/C%2B%2B) class library
and a widget toolkit with full mouse support for creating a text-based user and a widget toolkit with full mouse support for creating a text-based user
interface. It's based on the Termcap library and has its own cursor interface. It's based on the Termcap library and has its own cursor
optimization and window management. optimization and window management.

View File

@ -11,6 +11,9 @@ Table of Contents
- [Memory Management](#memory-management) - [Memory Management](#memory-management)
- [Event Processing](#event-processing) - [Event Processing](#event-processing)
- [Event handler reimplementation](#event-handler-reimplementation) - [Event handler reimplementation](#event-handler-reimplementation)
- [Event types](#available-event-types)
- [Timer event](#using-a-timer-event)
- [User event](#using-a-user-event)
- [Signals and Callbacks](#signals-and-callbacks) - [Signals and Callbacks](#signals-and-callbacks)
- [Default signals](#the-final-cut-widgets-emit-the-following-default-signals) - [Default signals](#the-final-cut-widgets-emit-the-following-default-signals)
- [Callback function](#example-of-a-callback-function) - [Callback function](#example-of-a-callback-function)
@ -245,16 +248,16 @@ Event Processing
---------------- ----------------
Calling `FApplication::exec()` starts the FINAL CUT main event loop. Calling `FApplication::exec()` starts the FINAL CUT main event loop.
While the event loop is running, the system constantly checks whether While the event loop is running, the system checks all the time whether
an event has occurred and sends it to the application's currently focused an event has occurred and sends it to the application's currently focused
object. The events of the terminal such as keystrokes, mouse actions or object. The events of the terminal, such as keystrokes, mouse actions, or
resizing the terminal are translated into `FEvent` objects and sent it to terminal size changing, are translated into `FEvent` objects, and sent them to
the active `FObject`. It is also possible to use `FApplication::sendEvent()` the active `FObject`. It is also possible to use `FApplication::sendEvent()`
or `FApplication::queueEvent()` to send your own events to an object. or `FApplication::queueEvent()` to send a specific event to an object.
`FObject`-derived objects process incoming events by reimplementing the `FObject`-derived objects process incoming events by reimplementing the
virtual method `event()`. The `FObject` itself calls only virtual method `event()`. The `FObject` itself can only call its own events
`onTimer()` or `onUserEvent()` and ignores all other events. The `onTimer()` and `onUserEvent()` and ignores all other events. The
`FObject`-derived class `FWidget` also reimplements the `event()` method `FObject`-derived class `FWidget` also reimplements the `event()` method
to handle further events. `FWidget` calls the `FWidget::onKeyPress` method to handle further events. `FWidget` calls the `FWidget::onKeyPress` method
when you press a key, or the `FWidget::onMouseDown` method when you click when you press a key, or the `FWidget::onMouseDown` method when you click
@ -269,18 +272,18 @@ For example, the method `FEvent::type()` returns the type
`fc::MouseDown_Event` when you press down a mouse button. `fc::MouseDown_Event` when you press down a mouse button.
Some event types have data that cannot store in an `FEvent` object. Some event types have data that cannot store in an `FEvent` object.
For example, a click event of the mouse must store which button it For example, a click event of the mouse must store which button is
triggered where the mouse pointer was at that time. In classes derived triggered and where the mouse pointer was at that time. In classes derived
from `FEvent`, such as `FMouseEvent()`, we store this data. from `FEvent`, such as `FMouseEvent()`, we store this data.
Widgets get their events from the `event()` method inherited from FObject. Widgets get their events from the `event()` method inherited from FObject.
The implementation of `event()` in `FWidget` forwards the most common event The implementation of `event()` in `FWidget` forwards the most common event
types to specific event handlers such as `FMouseEvent()`, `FKeyEvent()` or types to specific event handlers such as `FMouseEvent()`, `FKeyEvent()` or
`FResizeEvent()`. There are many other event types. It is also possible to `FResizeEvent()`. There are many other event types. You can create own event
create own event types and send them to other objects. types and send them to other objects and widgets.
**The FINAL CUT event types:** ### Available event types ###
```cpp ```cpp
enum events enum events
{ {
@ -312,6 +315,12 @@ enum events
``` ```
### Using a timer event ###
The following example starts a periodic timer that triggers an `FTimerEvent()`
every 100 ms. The virtual method `onTimer()` is then called each time in the
same dialog object.
**File:** *timer.cpp* **File:** *timer.cpp*
```cpp ```cpp
#include <final/final.h> #include <final/final.h>
@ -375,6 +384,120 @@ g++ -O2 -lfinal -std=c++11 timer.cpp -o timer
``` ```
### Using a user event ###
You can use the `FUserEvent()` to create a individual event and send it to a
specific object. If you want to create more than one user event, you can
specify an identification number (0 in the example below) to identify the
different events. This number can get later with `getUserId()`.
User events should be generated in the main event loop. For this purpose,
the class `FApplication` provides the virtual method
`processExternalUserEvent()`. This method can be overwritten in a derived
class and filled with user code.
The following example reads the average system load and creates a user event
when a value changes. This event sends the current values to an `FLabel`
widget and displays them in the terminal.
**File:** *user-event.cpp*
```cpp
#include <stdlib.h>
#include <final/final.h>
#define _BSD_SOURCE 1
#define _DEFAULT_SOURCE 1
using LoadAvg = double[3];
using namespace finalcut;
class extendedApplication : public FApplication
{
public:
extendedApplication (const int& argc, char* argv[])
: FApplication(argc, argv)
{ }
private:
void processExternalUserEvent() override
{
if ( getMainWidget() )
{
if ( getloadavg(load_avg, 3) < 0 )
FApplication::getLog()->error("Can't get load average values");
if ( last_avg[0] != load_avg[0]
|| last_avg[1] != load_avg[1]
|| last_avg[2] != load_avg[2] )
{
FUserEvent user_event(fc::User_Event, 0);
user_event.setData (FDataPtr(&load_avg));
FApplication::sendEvent (getMainWidget(), &user_event);
}
for (std::size_t i = 0; i < 3; i++)
last_avg[i] = load_avg[i];
}
}
// Data member
LoadAvg load_avg{}, last_avg{};
};
class dialogWidget final : public FDialog
{
public:
explicit dialogWidget (FWidget* parent = nullptr)
: FDialog{"User event", parent}
{
FDialog::setGeometry (FPoint{25, 5}, FSize{40, 6});
loadavg_label.setGeometry (FPoint{2, 2}, FSize{36, 1});
}
private:
void onUserEvent (FUserEvent* ev) override
{
FDataPtr dataPtr = ev->getData();
auto& lavg = *(reinterpret_cast<LoadAvg*>(dataPtr));
std::setlocale(LC_NUMERIC, "C");
loadavg_label.clear();
loadavg_label << "Load average: " << lavg[0] << ", "
<< lavg[1] << ", "
<< lavg[2] << " ";
loadavg_label.redraw();
}
FLabel loadavg_label{this};
};
int main (int argc, char* argv[])
{
extendedApplication app(argc, argv);
dialogWidget dialog(&app);
FWidget::setMainWidget(&dialog);
dialog.show();
return app.exec();
}
```
<figure class="image">
<img src="first-steps_user-event.cpp.png" alt="user-event.cpp">
<figcaption>Figure 5. User event generation</figcaption>
</figure>
<br /><br />
*(Note: You can close the window with the mouse,
<kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Ctrl</kbd>+<kbd>^</kbd>)*
After entering the source code in *user-event.cpp* you can compile
the above program with gcc:
```cpp
g++ -O2 -lfinal -std=c++11 user-event.cpp -o user-event
```
Signals and Callbacks Signals and Callbacks
--------------------- ---------------------
@ -387,46 +510,154 @@ clicked by a keyboard or mouse, it sends the string "clicked". A signal
handler explicitly provided by Widget, in the form of a callback function handler explicitly provided by Widget, in the form of a callback function
or a callback method, can react to such a signal. or a callback method, can react to such a signal.
A callback function is always structured as follows: A callback function has no return value and can have various arguments:
```cpp ```cpp
void cb_function (FWidget* w, FDataPtr data) void cb_function (FWidget* w, int* i, double* d, ...)
{...} {...}
``` ```
The structure of a callback method is the same: The structure of a callback method is the same:
```cpp ```cpp
void classname::cb_methode (FWidget* w, FDataPtr data) void classname::cb_methode (FWidget* w, int* i, double* d, ...)
{...} {...}
``` ```
We use the `addCallback()` method of the `FWidget` class to connect We use the `addCallback()` method of the `FWidget` class to connect
to other widget objects. to other widget objects.
For calling functions and static methods: 1. For calling functions or static methods via a pointer:
```cpp ```cpp
template<typename Function
, typename FunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal void FWidget::addCallback ( const FString& cb_signal
, FCallback cb_handler , Function&& cb_function
, FDataPtr data ) , Args&&... args)
{...} {...}
``` ```
For calling a member method of a specific instance: 2. For calling functions or static methods via a reference:
```cpp ```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal void FWidget::addCallback ( const FString& cb_signal
, FWidget* cb_instance , Function& cb_function
, FMemberCallback cb_handler , Args&&... args)
, FDataPtr data )
{...} {...}
``` ```
There are two macros `F_FUNCTION_CALLBACK` and `F_METHOD_CALLBACK` to avoid 3. For calling a member method of a specific instance:
having to deal with necessary type conversions. With `delCallback()` you can
remove a connection to a signal handler or a widget. Alternatively, you can ```cpp
use `delCallbacks()` to remove all existing callbacks from an object. template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename MemberFunctionPointer<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_member
, Args&&... args)
{...}
```
4. For calling a std::bind call wrapper or a lambda expression:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function&& cb_function
, Args&&... args)
{...}
```
5. For calling a std::bind call wrapper to a specific instance:
```cpp
template<typename Object
, typename Function
, typename ObjectPointer<Object>::type = nullptr
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Object&& cb_instance
, Function&& cb_function
, Args&&... args)
{...}
```
6. For calling a lambda function that has been stored in a variable
with the keyword auto:
```cpp
template<typename Function
, typename ClassObject<Function>::type = nullptr
, typename... Args>
void FWidget::addCallback ( const FString& cb_signal
, Function& cb_function
, Args&&... args)
{...}
```
With `delCallback(...)` you can remove a connection to a signal handler
or a widget instance. Alternatively, you can use `delCallbacks()` to
remove all existing callbacks from an object.
1. To delete functions or static methods callbacks via a pointer:
```cpp
template<typename FunctionPtr
, typename FunctionPointer<FunctionPtr>::type = nullptr>
void FWidget::delCallback (FunctionPtr&& cb_func_ptr)
{...}
```
2. To delete functions or static methods callbacks via a reference:
```cpp
template<typename Function
, typename FunctionReference<Function>::type = nullptr>
void FWidget::delCallback (Function& cb_function)
{...}
```
3. To delete all callbacks from a specific instance:
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void FWidget::delCallback (Object&& cb_instance)
{...}
```
4. To delete all callbacks of a signal:
```cpp
void delCallback (const FString& cb_signal)
{...}
```
5. To delete all callbacks of a signal and specific instance:
```cpp
template<typename Object
, typename ObjectPointer<Object>::type = nullptr>
void delCallback (const FString& cb_signal, Object&& cb_instance)
{...}
```
6. To delete all callbacks from a widget:
```cpp
void delCallback()
{...}
```
### The FINAL CUT widgets emit the following default signals ### ### The FINAL CUT widgets emit the following default signals ###
@ -486,10 +717,8 @@ use `delCallbacks()` to remove all existing callbacks from an object.
using namespace finalcut; using namespace finalcut;
void cb_changeText (FWidget* w, FDataPtr data) void cb_changeText (const FButton& button, FLabel& label)
{ {
FButton& button = *(static_cast<FButton*>(w));
FLabel& label = *(static_cast<FLabel*>(data));
label.clear(); label.clear();
label << "The " << button.getClassName() << " was pressed"; label << "The " << button.getClassName() << " was pressed";
label.redraw(); label.redraw();
@ -512,9 +741,10 @@ int main (int argc, char* argv[])
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
button.addCallback button.addCallback
( (
"clicked", "clicked", // Callback signal
F_FUNCTION_CALLBACK (&cb_changeText), &cb_changeText, // Function pointer
&label std::cref(button), // First function argument
std::ref(label) // Second function argument
); );
FWidget::setMainWidget(&dialog); FWidget::setMainWidget(&dialog);
@ -524,7 +754,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_callback-function.cpp.png" alt="callback-function.cpp"> <img src="first-steps_callback-function.cpp.png" alt="callback-function.cpp">
<figcaption>Figure 5. Button with a callback function</figcaption> <figcaption>Figure 6. Button with a callback function</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -560,11 +790,9 @@ int main (int argc, char* argv[])
// Connect the button signal "clicked" with the lambda expression // Connect the button signal "clicked" with the lambda expression
button.addCallback button.addCallback
( (
"clicked", "clicked", // Callback signal
[] (FWidget* w, FDataPtr d) [] (FButton& button, FDialog& dgl) // Lambda function
{ {
FButton& button = *(static_cast<FButton*>(w));
if ( button.getY() != 2 ) if ( button.getY() != 2 )
{ {
button.setPos (FPoint{15, 2}); button.setPos (FPoint{15, 2});
@ -576,9 +804,10 @@ int main (int argc, char* argv[])
button.setText("&bottom"); button.setText("&bottom");
} }
static_cast<FDialog*>(d)->redraw(); dgl.redraw();
}, },
&dialog std::ref(button), // First function argument
std::ref(dialog) // Second function argument
); );
FWidget::setMainWidget(&dialog); FWidget::setMainWidget(&dialog);
@ -588,7 +817,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_callback-lambda.cpp.png" alt="callback-lambda.cpp"> <img src="first-steps_callback-lambda.cpp.png" alt="callback-lambda.cpp">
<figcaption>Figure 6. Button with lambda expression callback.</figcaption> <figcaption>Figure 7. Button with lambda expression callback.</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -625,9 +854,10 @@ class dialogWidget : public FDialog
// Connect the button signal "clicked" with the callback method // Connect the button signal "clicked" with the callback method
button.addCallback button.addCallback
( (
"clicked", "clicked", // Callback signal
F_METHOD_CALLBACK (this, &FApplication::cb_exitApp), finalcut::getFApplication(), // Class instance
nullptr &finalcut::FApplication::cb_exitApp, // Method pointer
this // Function argument
); );
} }
@ -646,7 +876,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_callback-method.cpp.png" alt="callback-method.cpp"> <img src="first-steps_callback-method.cpp.png" alt="callback-method.cpp">
<figcaption>Figure 7. Button with a callback method</figcaption> <figcaption>Figure 8. Button with a callback method</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -687,45 +917,22 @@ class dialogWidget : public FDialog
label.setAlignment (fc::alignRight); label.setAlignment (fc::alignRight);
label.setForegroundColor (fc::Black); label.setForegroundColor (fc::Black);
plus.setGeometry (FPoint{3, 3}, size); plus.setGeometry (FPoint{3, 3}, size);
minus.setGeometry (FPoint{13, 3}, size); minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
plus.setNoUnderline(); plus.setNoUnderline();
minus.setNoUnderline(); minus.setNoUnderline();
// Connect the button signal "clicked" with the callback method // Connect the button signal "clicked" with the callback method
plus.addCallback plus.addCallback ("clicked", this, &dialogWidget::cb_plus);
( minus.addCallback ("clicked", this, &dialogWidget::cb_minus);
"clicked",
F_METHOD_CALLBACK (this, &dialogWidget::cb_plus)
);
minus.addCallback
(
"clicked",
F_METHOD_CALLBACK (this, &dialogWidget::cb_minus)
);
// Connect own signals // Connect own signals
addCallback addCallback ("hot", this, &dialogWidget::cb_set_red);
( addCallback ("regular", this, &dialogWidget::cb_set_black);
"hot", addCallback ("cold", this, &dialogWidget::cb_set_blue);
F_METHOD_CALLBACK (this, &dialogWidget::cb_set_red)
);
addCallback
(
"regular",
F_METHOD_CALLBACK (this, &dialogWidget::cb_set_black)
);
addCallback
(
"cold",
F_METHOD_CALLBACK (this, &dialogWidget::cb_set_blue)
);
} }
private: private:
void cb_plus (FWidget*, FDataPtr) void cb_plus()
{ {
if ( t < 100 ) if ( t < 100 )
t++; t++;
@ -738,7 +945,7 @@ class dialogWidget : public FDialog
setTemperature(); setTemperature();
} }
void cb_minus (FWidget*, FDataPtr) void cb_minus()
{ {
if ( t > -99 ) if ( t > -99 )
t--; t--;
@ -751,17 +958,17 @@ class dialogWidget : public FDialog
setTemperature(); setTemperature();
} }
void cb_set_blue (FWidget*, FDataPtr) void cb_set_blue()
{ {
label.setForegroundColor (fc::Blue); label.setForegroundColor (fc::Blue);
} }
void cb_set_black (FWidget*, FDataPtr) void cb_set_black()
{ {
label.setForegroundColor (fc::Black); label.setForegroundColor (fc::Black);
} }
void cb_set_red (FWidget*, FDataPtr) void cb_set_red()
{ {
label.setForegroundColor (fc::Red); label.setForegroundColor (fc::Red);
} }
@ -790,7 +997,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_emit-signal.cpp.png" alt="emit-signal.cpp"> <img src="first-steps_emit-signal.cpp.png" alt="emit-signal.cpp">
<figcaption>Figure 8. Callbacks with custom signals</figcaption> <figcaption>Figure 9. Callbacks with custom signals</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -831,7 +1038,7 @@ If you want to ignore padding spaces, you must force this with the
<figure class="image"> <figure class="image">
<img src="widget-coordinates.svg" alt="widget coordinates"> <img src="widget-coordinates.svg" alt="widget coordinates">
<figcaption>Figure 9. Widget coordinates</figcaption> <figcaption>Figure 10. Widget coordinates</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -881,7 +1088,7 @@ methods.
<figure class="image"> <figure class="image">
<img src="widget-lengths.svg" alt="widget lengths"> <img src="widget-lengths.svg" alt="widget lengths">
<figcaption>Figure 10. Width and height of a widget</figcaption> <figcaption>Figure 11. Width and height of a widget</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -934,7 +1141,7 @@ absolute geometry values as a `FRect` object, you can call the method
<figure class="image"> <figure class="image">
<img src="widget-geometry.svg" alt="widget geometry"> <img src="widget-geometry.svg" alt="widget geometry">
<figcaption>Figure 11. Geometry of widgets</figcaption> <figcaption>Figure 12. Geometry of widgets</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -994,7 +1201,7 @@ class dialogWidget : public FDialog
button.setGeometry (FPoint{1, 1}, FSize{12, 1}, false); button.setGeometry (FPoint{1, 1}, FSize{12, 1}, false);
input.setGeometry (FPoint{2, 3}, FSize{12, 1}, false); input.setGeometry (FPoint{2, 3}, FSize{12, 1}, false);
// Set dialog geometry and calling adjustSize() // Set dialog geometry and calling adjustSize()
setGeometry (FPoint{25, 5}), FSize{40, 12}); setGeometry (FPoint{25, 5}, FSize{40, 12});
setMinimumSize (FSize{25, 9}); setMinimumSize (FSize{25, 9});
} }
@ -1068,7 +1275,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_size-adjustment.cpp.png" alt="size-adjustment.cpp"> <img src="first-steps_size-adjustment.cpp.png" alt="size-adjustment.cpp">
<figcaption>Figure 12. Dynamic layout</figcaption> <figcaption>Figure 13. Dynamic layout</figcaption>
</figure> </figure>
<br /><br /> <br /><br />
@ -1135,12 +1342,13 @@ class dialogWidget : public FDialog
setGeometry (FPoint{28, 2}, FSize{24, 21}); setGeometry (FPoint{28, 2}, FSize{24, 21});
scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11}); scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11});
scrollview.setScrollSize(FSize{60, 27}); scrollview.setScrollSize(FSize{60, 27});
const auto& wc = getFWidgetColors(); // Attention: getColorTheme() requires an initialized terminal
setColor (wc.label_inactive_fg, wc.dialog_bg); const auto& wc = getColorTheme();
setColor (wc->label_inactive_fg, wc->dialog_bg);
scrollview.clearArea(); scrollview.clearArea();
FColorPair red (fc::LightRed, wc.dialog_bg); FColorPair red (fc::LightRed, wc->dialog_bg);
FColorPair black (fc::Black, wc.dialog_bg); FColorPair black (fc::Black, wc->dialog_bg);
FColorPair cyan (fc::Cyan, wc.dialog_bg); FColorPair cyan (fc::Cyan, wc->dialog_bg);
static std::vector<direction> d static std::vector<direction> d
{ {
@ -1167,8 +1375,7 @@ class dialogWidget : public FDialog
btn->addCallback btn->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &dialogWidget::cb_button), this, &dialogWidget::cb_button, std::get<2>(b)
static_cast<FDataPtr>(&std::get<2>(b))
); );
}; };
} }
@ -1176,10 +1383,9 @@ class dialogWidget : public FDialog
private: private:
typedef std::tuple<FString, FPoint, FPoint, FColorPair> direction; typedef std::tuple<FString, FPoint, FPoint, FColorPair> direction;
void cb_button (FWidget*, FDataPtr data) void cb_button (const FPoint& p)
{ {
FPoint* p = static_cast<FPoint*>(data); scrollview.scrollTo(p);
scrollview.scrollTo(*p);
} }
FScrollView scrollview{this}; FScrollView scrollview{this};
@ -1188,6 +1394,7 @@ class dialogWidget : public FDialog
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
FApplication app(argc, argv); FApplication app(argc, argv);
app.initTerminal(); // Terminal initialization
dialogWidget dialog(&app); dialogWidget dialog(&app);
FWidget::setMainWidget(&dialog); FWidget::setMainWidget(&dialog);
dialog.show(); dialog.show();
@ -1196,7 +1403,7 @@ int main (int argc, char* argv[])
``` ```
<figure class="image"> <figure class="image">
<img src="first-steps_scrollview.cpp.png" alt="scrollview.cpp"> <img src="first-steps_scrollview.cpp.png" alt="scrollview.cpp">
<figcaption>Figure 13. Dialog with a scrolling viewport</figcaption> <figcaption>Figure 14. Dialog with a scrolling viewport</figcaption>
</figure> </figure>
<br /><br /> <br /><br />

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

View File

@ -1,7 +1,7 @@
Framebuffer Framebuffer
=========== ===========
The Final Cut determines the used number of bits per pixel (bpp) FINAL CUT determines the used number of bits per pixel (bpp)
for Linux framebuffer console to determine whether 16 (or more) for Linux framebuffer console to determine whether 16 (or more)
different background colors can be displayed. Therefore your user different background colors can be displayed. Therefore your user
needs read-access to the framebuffer device (/dev/fb0 or /dev/fb/0). needs read-access to the framebuffer device (/dev/fb0 or /dev/fb/0).

29
doc/mouse-control.md Normal file
View File

@ -0,0 +1,29 @@
Title bar actions on mouse clicks
=================================
The FINAL CUT title bar of dialog windows has different behaviors on mouse clicks.
Clicking on the title bar
-------------------------
* A left-click activates and raises the window. After that, you can drag the window with the mouse.
* A middle-click activates and lower the window.
* A right-click activates the window and keeps its current position in the window stack.
* A double-click maximizes or restores the window size for a resizable dialog.
Clicking the title bar buttons
------------------------------
* Single-clicking on the title bar menu button opens the title bar menu.
* Double-clicking on the title bar menu button closes the dialog.
* Single-clicking on the zoom button maximizes the window size.
* Single-clicking on the unzoom button restores the window size.
Dialog resize corner
--------------------
If you click and drag the left mouse button in the lower right corner of the window, you can change the size of a resizable dialog.

View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="43.074867"
viewBox="0 0 509.50272 43.074862"
width="509.50272"
version="1.1"
id="user-theme-own-palette"
sodipodi:docname="user-theme-own-palette.svg"
inkscape:version="0.92.1 r15371">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="1984"
id="namedview21"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="8.3138663"
inkscape:cx="31.395854"
inkscape:cy="8.1120765"
inkscape:window-x="0"
inkscape:window-y="55"
inkscape:window-maximized="1"
inkscape:current-layer="user-theme-own-palette"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-bbox="true" />
<metadata
id="metadata">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53" />
<rect
id="Black"
style="fill:#000000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="0.25" />
<rect
id="Blue"
style="fill:#23212c;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="32.380764" />
<rect
id="Green"
style="fill:#26937c;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="64.511536" />
<rect
id="Cyan"
style="fill:#cfb3a8;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="96.642288" />
<rect
id="Red"
style="fill:#ba1a1a;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="128.77304" />
<rect
id="Magenta"
style="fill:#b218b2;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="160.90382" />
<rect
id="Brown"
style="fill:#e8871f;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="193.03458" />
<rect
id="LightGray"
style="fill:#fffbe4;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="225.16534" />
<rect
id="DarkGray"
style="fill:#3a3637;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="257.29608" />
<rect
id="LightBlue"
style="fill:#a5a5b1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="289.42688" />
<rect
id="LightGreen"
style="fill:#5eeb5c;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="321.55765" />
<rect
id="LightCyan"
style="fill:#62bff8;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="353.68842" />
<rect
id="LightRed"
style="fill:#ee4444;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="385.81915" />
<rect
id="LightMagenta"
style="fill:#e9adff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="417.94992" />
<rect
id="Yellow"
style="fill:#f8efa6;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="450.08069" />
<rect
id="White"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="482.21146" />
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="13.822153"
y="42.771538"
id="0"><tspan
sodipodi:role="line"
id="tspan4501"
x="13.822153"
y="42.771538">0</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="46.455204"
y="42.852036"
id="1"><tspan
sodipodi:role="line"
id="tspan4633"
x="46.455204"
y="42.852036">1</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="78.20282"
y="42.852036"
id="2"><tspan
sodipodi:role="line"
id="tspan4635"
x="78.20282"
y="42.852036">2</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="110.20156"
y="42.771538"
id="3"><tspan
sodipodi:role="line"
id="tspan4637"
x="110.20156"
y="42.771538">3</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="142.32588"
y="42.852036"
id="4"><tspan
sodipodi:role="line"
id="tspan4639"
x="142.32588"
y="42.852036">4</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="174.3343"
y="42.687824"
id="5"><tspan
sodipodi:role="line"
id="tspan4641"
x="174.3343"
y="42.687824">5</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="206.51335"
y="42.771538"
id="6"><tspan
sodipodi:role="line"
id="tspan4643"
x="206.51335"
y="42.771538">6</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="238.70207"
y="42.768318"
id="7"><tspan
sodipodi:role="line"
id="tspan4645"
x="238.70207"
y="42.768318">7</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="270.84891"
y="42.768318"
id="8"><tspan
sodipodi:role="line"
id="tspan4647"
x="270.84891"
y="42.768318">8</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="303.04733"
y="42.768318"
id="9"><tspan
sodipodi:role="line"
id="tspan4649"
x="303.04733"
y="42.768318">9</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="334.8851"
y="42.771538"
id="10"><tspan
sodipodi:role="line"
id="tspan4651"
x="334.8851"
y="42.771538">10</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="367.76285"
y="42.852036"
id="11"><tspan
sodipodi:role="line"
id="tspan4653"
x="367.76285"
y="42.852036">11</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="399.15305"
y="42.852036"
id="12"><tspan
sodipodi:role="line"
id="tspan4663"
x="399.15305"
y="42.852036">12</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="431.2355"
y="42.771538"
id="13"><tspan
sodipodi:role="line"
id="tspan4665"
x="431.2355"
y="42.771538">13</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="463.23425"
y="42.852036"
id="14"><tspan
sodipodi:role="line"
id="tspan4667"
x="463.23425"
y="42.852036">14</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="495.41333"
y="42.771538"
id="15"><tspan
sodipodi:role="line"
id="tspan4669"
x="495.41333"
y="42.771538">15</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="43.074867"
viewBox="0 0 509.50272 43.074862"
width="509.50272"
version="1.1"
id="user-theme-own-palette"
sodipodi:docname="user-theme-own-palette.svg"
inkscape:version="0.92.1 r15371">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="1984"
id="namedview21"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="8.3138663"
inkscape:cx="31.395854"
inkscape:cy="8.1120765"
inkscape:window-x="0"
inkscape:window-y="55"
inkscape:window-maximized="1"
inkscape:current-layer="user-theme-own-palette"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-bbox="true" />
<metadata
id="metadata">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53" />
<rect
id="Black"
style="fill:#000000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="0.25" />
<rect
id="Blue"
style="fill:#4158b3;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="32.380764" />
<rect
id="Green"
style="fill:#187818;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="64.511536" />
<rect
id="Cyan"
style="fill:#4e6672;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="96.642288" />
<rect
id="Red"
style="fill:#a54040;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="128.77304" />
<rect
id="Magenta"
style="fill:#b218b2;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="160.90382" />
<rect
id="Brown"
style="fill:#e8871f;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="193.03458" />
<rect
id="LightGray"
style="fill:#dcdcdc;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="225.16534" />
<rect
id="DarkGray"
style="fill:#273339;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="257.29608" />
<rect
id="LightBlue"
style="fill:#b0b0b8;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="289.42688" />
<rect
id="LightGreen"
style="fill:#5eeb5c;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="321.55765" />
<rect
id="LightCyan"
style="fill:#62bff8;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="353.68842" />
<rect
id="LightRed"
style="fill:#dd5145;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="385.81915" />
<rect
id="LightMagenta"
style="fill:#e9adff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="417.94992" />
<rect
id="Yellow"
style="fill:#fbe867;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="450.08069" />
<rect
id="White"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="482.21146" />
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="13.822153"
y="42.771538"
id="0"><tspan
sodipodi:role="line"
id="tspan4501"
x="13.822153"
y="42.771538">0</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="46.455204"
y="42.852036"
id="1"><tspan
sodipodi:role="line"
id="tspan4633"
x="46.455204"
y="42.852036">1</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="78.20282"
y="42.852036"
id="2"><tspan
sodipodi:role="line"
id="tspan4635"
x="78.20282"
y="42.852036">2</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="110.20156"
y="42.771538"
id="3"><tspan
sodipodi:role="line"
id="tspan4637"
x="110.20156"
y="42.771538">3</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="142.32588"
y="42.852036"
id="4"><tspan
sodipodi:role="line"
id="tspan4639"
x="142.32588"
y="42.852036">4</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="174.3343"
y="42.687824"
id="5"><tspan
sodipodi:role="line"
id="tspan4641"
x="174.3343"
y="42.687824">5</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="206.51335"
y="42.771538"
id="6"><tspan
sodipodi:role="line"
id="tspan4643"
x="206.51335"
y="42.771538">6</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="238.70207"
y="42.768318"
id="7"><tspan
sodipodi:role="line"
id="tspan4645"
x="238.70207"
y="42.768318">7</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="270.84891"
y="42.768318"
id="8"><tspan
sodipodi:role="line"
id="tspan4647"
x="270.84891"
y="42.768318">8</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="303.04733"
y="42.768318"
id="9"><tspan
sodipodi:role="line"
id="tspan4649"
x="303.04733"
y="42.768318">9</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="334.8851"
y="42.771538"
id="10"><tspan
sodipodi:role="line"
id="tspan4651"
x="334.8851"
y="42.771538">10</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="367.76285"
y="42.852036"
id="11"><tspan
sodipodi:role="line"
id="tspan4653"
x="367.76285"
y="42.852036">11</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="399.15305"
y="42.852036"
id="12"><tspan
sodipodi:role="line"
id="tspan4663"
x="399.15305"
y="42.852036">12</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="431.2355"
y="42.771538"
id="13"><tspan
sodipodi:role="line"
id="tspan4665"
x="431.2355"
y="42.771538">13</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="463.23425"
y="42.852036"
id="14"><tspan
sodipodi:role="line"
id="tspan4667"
x="463.23425"
y="42.852036">14</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="495.41333"
y="42.771538"
id="15"><tspan
sodipodi:role="line"
id="tspan4669"
x="495.41333"
y="42.771538">15</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="43.074867"
viewBox="0 0 509.50272 43.074862"
width="509.50272"
version="1.1"
id="user-theme-own-palette"
sodipodi:docname="user-theme-own-palette.svg"
inkscape:version="0.92.1 r15371">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="1984"
id="namedview21"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="8.3138663"
inkscape:cx="31.395854"
inkscape:cy="8.1120765"
inkscape:window-x="0"
inkscape:window-y="55"
inkscape:window-maximized="1"
inkscape:current-layer="user-theme-own-palette"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-bbox="true" />
<metadata
id="metadata">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53" />
<rect
id="Black"
style="fill:#000000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="0.25" />
<rect
id="Blue"
style="fill:#103b9e;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="32.380764" />
<rect
id="Green"
style="fill:#187818;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="64.511536" />
<rect
id="Cyan"
style="fill:#556acf;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="96.642288" />
<rect
id="Red"
style="fill:#ba1a1a;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="128.77304" />
<rect
id="Magenta"
style="fill:#b218b2;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="160.90382" />
<rect
id="Brown"
style="fill:#e8871f;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="193.03458" />
<rect
id="LightGray"
style="fill:#bcbcbc;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="225.16534" />
<rect
id="DarkGray"
style="fill:#505050;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="257.29608" />
<rect
id="LightBlue"
style="fill:#80a4ec;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="289.42688" />
<rect
id="LightGreen"
style="fill:#5eeb5c;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="321.55765" />
<rect
id="LightCyan"
style="fill:#62bff8;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="353.68842" />
<rect
id="LightRed"
style="fill:#ee4444;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="385.81915" />
<rect
id="LightMagenta"
style="fill:#e9adff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="417.94992" />
<rect
id="Yellow"
style="fill:#fbe867;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="450.08069" />
<rect
id="White"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="482.21146" />
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="13.822153"
y="42.771538"
id="0"><tspan
sodipodi:role="line"
id="tspan4501"
x="13.822153"
y="42.771538">0</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="46.455204"
y="42.852036"
id="1"><tspan
sodipodi:role="line"
id="tspan4633"
x="46.455204"
y="42.852036">1</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="78.20282"
y="42.852036"
id="2"><tspan
sodipodi:role="line"
id="tspan4635"
x="78.20282"
y="42.852036">2</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="110.20156"
y="42.771538"
id="3"><tspan
sodipodi:role="line"
id="tspan4637"
x="110.20156"
y="42.771538">3</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="142.32588"
y="42.852036"
id="4"><tspan
sodipodi:role="line"
id="tspan4639"
x="142.32588"
y="42.852036">4</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="174.3343"
y="42.687824"
id="5"><tspan
sodipodi:role="line"
id="tspan4641"
x="174.3343"
y="42.687824">5</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="206.51335"
y="42.771538"
id="6"><tspan
sodipodi:role="line"
id="tspan4643"
x="206.51335"
y="42.771538">6</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="238.70207"
y="42.768318"
id="7"><tspan
sodipodi:role="line"
id="tspan4645"
x="238.70207"
y="42.768318">7</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="270.84891"
y="42.768318"
id="8"><tspan
sodipodi:role="line"
id="tspan4647"
x="270.84891"
y="42.768318">8</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="303.04733"
y="42.768318"
id="9"><tspan
sodipodi:role="line"
id="tspan4649"
x="303.04733"
y="42.768318">9</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="334.8851"
y="42.771538"
id="10"><tspan
sodipodi:role="line"
id="tspan4651"
x="334.8851"
y="42.771538">10</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="367.76285"
y="42.852036"
id="11"><tspan
sodipodi:role="line"
id="tspan4653"
x="367.76285"
y="42.852036">11</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="399.15305"
y="42.852036"
id="12"><tspan
sodipodi:role="line"
id="tspan4663"
x="399.15305"
y="42.852036">12</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="431.2355"
y="42.771538"
id="13"><tspan
sodipodi:role="line"
id="tspan4665"
x="431.2355"
y="42.771538">13</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="463.23425"
y="42.852036"
id="14"><tspan
sodipodi:role="line"
id="tspan4667"
x="463.23425"
y="42.852036">14</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="495.41333"
y="42.771538"
id="15"><tspan
sodipodi:role="line"
id="tspan4669"
x="495.41333"
y="42.771538">15</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="43.074867"
viewBox="0 0 252.45662 43.074862"
width="252.45662"
version="1.1"
id="user-theme-own-palette"
sodipodi:docname="user-theme-fc8-palette.svg"
inkscape:version="0.92.1 r15371">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="1984"
id="namedview21"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="10.738479"
inkscape:cx="126.22831"
inkscape:cy="21.537433"
inkscape:window-x="0"
inkscape:window-y="55"
inkscape:window-maximized="1"
inkscape:current-layer="user-theme-own-palette"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-bbox="true" />
<metadata
id="metadata">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53" />
<rect
id="Black"
style="fill:#000000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="0.25" />
<rect
id="Blue"
style="fill:#103b9e;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="32.380764" />
<rect
id="Green"
style="fill:#187818;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="64.511536" />
<rect
id="Cyan"
style="fill:#a0b2b2;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="96.642288" />
<rect
id="Red"
style="fill:#b21818;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="128.77304" />
<rect
id="Magenta"
style="fill:#b218b2;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="160.90382" />
<rect
id="Brown"
style="fill:#e8871f;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="193.03458" />
<rect
id="LightGray"
style="fill:#e0e0e0;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="225.16534" />
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="13.822153"
y="42.771538"
id="0"><tspan
sodipodi:role="line"
id="tspan4501"
x="13.822153"
y="42.771538">0</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="46.455204"
y="42.852036"
id="1"><tspan
sodipodi:role="line"
id="tspan4633"
x="46.455204"
y="42.852036">1</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="78.20282"
y="42.852036"
id="2"><tspan
sodipodi:role="line"
id="tspan4635"
x="78.20282"
y="42.852036">2</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="110.20156"
y="42.771538"
id="3"><tspan
sodipodi:role="line"
id="tspan4637"
x="110.20156"
y="42.771538">3</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="142.32588"
y="42.852036"
id="4"><tspan
sodipodi:role="line"
id="tspan4639"
x="142.32588"
y="42.852036">4</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="174.3343"
y="42.687824"
id="5"><tspan
sodipodi:role="line"
id="tspan4641"
x="174.3343"
y="42.687824">5</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="206.51335"
y="42.771538"
id="6"><tspan
sodipodi:role="line"
id="tspan4643"
x="206.51335"
y="42.771538">6</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="238.70207"
y="42.768318"
id="7"><tspan
sodipodi:role="line"
id="tspan4645"
x="238.70207"
y="42.768318">7</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="43.074867"
viewBox="0 0 509.50272 43.074862"
width="509.50272"
version="1.1"
id="user-theme-vga-palette"
sodipodi:docname="user-theme-vga-palette.svg"
inkscape:version="0.92.1 r15371">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="1984"
id="namedview21"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="8.3138663"
inkscape:cx="31.395854"
inkscape:cy="8.1120765"
inkscape:window-x="0"
inkscape:window-y="55"
inkscape:window-maximized="1"
inkscape:current-layer="user-theme-vga-palette"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-bbox="true" />
<metadata
id="metadata">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs53" />
<rect
id="Black"
style="fill:#000000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="0.25" />
<rect
id="Blue"
style="fill:#0000aa;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="32.380764" />
<rect
id="Green"
style="fill:#00aa00;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="64.511536" />
<rect
id="Cyan"
style="fill:#00aaaa;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="96.642288" />
<rect
id="Red"
style="fill:#aa0000;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="128.77304" />
<rect
id="Magenta"
style="fill:#aa00aa;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="160.90382" />
<rect
id="Brown"
style="fill:#aa5500;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="193.03458" />
<rect
id="LightGray"
style="fill:#aaaaaa;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="225.16534" />
<rect
id="DarkGray"
style="fill:#555555;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="257.29608" />
<rect
id="LightBlue"
style="fill:#5555ff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="289.42688" />
<rect
id="LightGreen"
style="fill:#55ff55;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="321.55765" />
<rect
id="LightCyan"
style="fill:#55ffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="353.68842" />
<rect
id="LightRed"
style="fill:#ff5555;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="385.81915" />
<rect
id="LightMagenta"
style="fill:#ff55ff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="417.94992" />
<rect
id="Yellow"
style="fill:#ffff55;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="450.08069" />
<rect
id="White"
style="fill:#ffffff;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
height="27.725"
width="27.041273"
y="0.25"
x="482.21146" />
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="13.822153"
y="42.771538"
id="0"><tspan
sodipodi:role="line"
id="tspan4501"
x="13.822153"
y="42.771538">0</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="46.455204"
y="42.852036"
id="1"><tspan
sodipodi:role="line"
id="tspan4633"
x="46.455204"
y="42.852036">1</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="78.20282"
y="42.852036"
id="2"><tspan
sodipodi:role="line"
id="tspan4635"
x="78.20282"
y="42.852036">2</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="110.20156"
y="42.771538"
id="3"><tspan
sodipodi:role="line"
id="tspan4637"
x="110.20156"
y="42.771538">3</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="142.32588"
y="42.852036"
id="4"><tspan
sodipodi:role="line"
id="tspan4639"
x="142.32588"
y="42.852036">4</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="174.3343"
y="42.687824"
id="5"><tspan
sodipodi:role="line"
id="tspan4641"
x="174.3343"
y="42.687824">5</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="206.51335"
y="42.771538"
id="6"><tspan
sodipodi:role="line"
id="tspan4643"
x="206.51335"
y="42.771538">6</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="238.70207"
y="42.768318"
id="7"><tspan
sodipodi:role="line"
id="tspan4645"
x="238.70207"
y="42.768318">7</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="270.84891"
y="42.768318"
id="8"><tspan
sodipodi:role="line"
id="tspan4647"
x="270.84891"
y="42.768318">8</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="303.04733"
y="42.768318"
id="9"><tspan
sodipodi:role="line"
id="tspan4649"
x="303.04733"
y="42.768318">9</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="334.8851"
y="42.771538"
id="10"><tspan
sodipodi:role="line"
id="tspan4651"
x="334.8851"
y="42.771538">10</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="367.76285"
y="42.852036"
id="11"><tspan
sodipodi:role="line"
id="tspan4653"
x="367.76285"
y="42.852036">11</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="399.15305"
y="42.852036"
id="12"><tspan
sodipodi:role="line"
id="tspan4663"
x="399.15305"
y="42.852036">12</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="431.2355"
y="42.771538"
id="13"><tspan
sodipodi:role="line"
id="tspan4665"
x="431.2355"
y="42.771538">13</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="463.23425"
y="42.852036"
id="14"><tspan
sodipodi:role="line"
id="tspan4667"
x="463.23425"
y="42.852036">14</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:13.18826675px;line-height:125%;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1"
x="495.41333"
y="42.771538"
id="15"><tspan
sodipodi:role="line"
id="tspan4669"
x="495.41333"
y="42.771538">15</tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

443
doc/user-theme.md Normal file
View File

@ -0,0 +1,443 @@
User Themes
===========
FINAL CUT supports color themes. That makes it possible to change the color
of all elements of a widget in the program. Also, you can adjust the color
palette to your preferences. If you want to switch back to the default
themes, you can always call the method `FApplication::setDefaultTheme()`
or `FApplication::setDarkTheme()` for the dark theme.
Widget Color Theme
------------------
FINAL CUT uses a default color scheme that the user can override in a
derived class of `FWidgetColors`. All widget colors are redefined in the
constructor by the method `setColorTheme()`.
```cpp
class myWidgetColors final : public finalcut::FWidgetColors
{
public:
myWidgetColors()
{
myWidgetColors::setColorTheme();
}
~myWidgetColors() override
{ }
const finalcut::FString getClassName() const override
{
return "myWidgetColors";
}
void myWidgetColors() override
{
... // Color definitions
}
};
```
For setting the widget colors, it is recommended to call the method
`FWidget::setColorTheme()` via the `FApplication` object to create a
new instance of the theme and assign it to the application.
```cpp
finalcut::FApplication app(argc, argv);
app.setColorTheme<myWidgetColors>();
```
In the following example, we will create the `BeeColorTheme`. For this
purpose, we will first create an include file that can be easily included
later in your application.
**File:** *widget-color-theme.h*
```cpp
#ifndef WIDGETCOLORTHEME_H
#define WIDGETCOLORTHEME_H
class BeeColorTheme final : public finalcut::FWidgetColors
{
public:
BeeColorTheme()
{
BeeColorTheme::setColorTheme();
}
~BeeColorTheme() override
{ }
const finalcut::FString getClassName() const override
{
return "BeeColorTheme";
}
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;
}
};
#endif // WIDGETCOLORTHEME_H
```
Color Palette Theme
-------------------
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 |
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
`FColorPalette`. The constructor gets as argument the function to set
a palette color. This function must have the following structure:
```cpp
setPalette(finalcut::FColor index, int red, int green, int blue);
```
A possible implementation could look as follows:
```cpp
class myColorPalette final : public finalcut::FColorPalette
{
public:
explicit myColorPalette (const FSetPalette& f)
: FColorPalette(f)
{ }
~myColorPalette()
{ }
const finalcut::FString getClassName() const override
{
return "myColorPalette";
}
void setColorPalette() override
{
... // Palette definitions
}
void resetColorPalette() override
{
setVGAdefaultPalette();
}
};
```
To set the colors of a palette theme, you should use the method
`FTerm::setColorPaletteTheme()`. This method creates a new instance and
saves it in the `FTerm` object.
```cpp
finalcut::FTerm::setColorPaletteTheme<myColorPalette>();
```
The standard VGA palette is part of the `FColorPalette` class. To set it,
use the method `setVGAdefaultPalette()`. You can use it to reset the color
palette of terminals that cannot reset to default values with escape
sequences.
<figure class="image">
<img src="user-theme-vga-palette.svg" alt="VGA palette">
<figcaption>Figure 1. VGA palette</figcaption>
</figure>
<br /><br />
The FINAL CUT eight-color palette `default8ColorPalette` is optimized for
the eight-color widget theme `default8ColorTheme`. It is for terminals
that cannot display more than eight colors.
<figure class="image">
<img src="user-theme-fc8-palette.svg" alt="FINAL CUT 8-color palette">
<figcaption>Figure 2. FINAL CUT 8-color palette</figcaption>
</figure>
<br /><br />
The FINAL CUT palette `default16ColorPalette` is the default 16-color
palette. It is optimized for the widget color theme `default16ColorTheme`.
<figure class="image">
<img src="user-theme-fc16-palette.svg" alt="FINAL CUT 16-color palette">
<figcaption>Figure 3. FINAL CUT 16-color palette</figcaption>
</figure>
<br /><br />
The second 16-color palette in FINAL CUT is for the dark theme. It was
adjusted for the widget color themes `default8ColorDarkTheme` and
`default16ColorDarkTheme`.
<figure class="image">
<img src="user-theme-fc16-dark-palette.svg" alt="FINAL CUT 16-color dark palette">
<figcaption>Figure 4. FINAL CUT 16-color dark palette</figcaption>
</figure>
<br /><br />
In the following example, we want to create the palette them
`BeeColorPalette`. For this purpose, we generate an include file again,
in which we implement the new palette class.
<figure class="image">
<img src="user-theme-bee-palette.svg" alt="Bee palette">
<figcaption>Figure 6. Bee palette</figcaption>
</figure>
<br /><br />
**File:** *color-palette-theme.h*
```cpp
#ifndef BEECOLORPALETTE_H
#define BEECOLORPALETTE_H
class BeeColorPalette final : public finalcut::FColorPalette
{
public:
explicit BeeColorPalette (const FSetPalette& f)
: FColorPalette(f)
{ }
~BeeColorPalette()
{ }
const finalcut::FString getClassName() const override
{
return "BeeColorPalette";
}
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);
}
void resetColorPalette() override
{
setVGAdefaultPalette();
}
};
#endif // BEECOLORPALETTE_H
```
Use of Themes
-------------
If you include the two include files above in your application, you can use
the widget color theme and the color palette theme. In the main function of
your application, the object instances of both classes are created and set.
<figure class="image">
<img src="user-theme.png" alt="User theme example">
<figcaption>Figure 7. User theme example</figcaption>
</figure>
<br /><br />
**File:** *theme.cpp*
```cpp
#include <final/final.h>
#include "widget-color-theme.h"
#include "color-palette-theme.h"
using namespace finalcut;
class dialogWidget final : public FDialog
{
public:
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.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
(
"clicked",
finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
);
Open.addCallback
(
"clicked",
this, &dialogWidget::cb_FileBrowse
);
}
private:
void cb_FileBrowse()
{
auto filename = FFileDialog::fileOpenChooser(this);
if ( ! filename.isEmpty() )
{
Input.setText(filename);
Input.redraw();
}
}
FMenuBar Menubar{this};
FMenu File{"&File", &Menubar};
FMenuItem New{"&New", &File};
FMenuItem Open{"&Open...", &File};
FMenu Edit{"&Edit", &Menubar};
FMenuItem Undo{"&Undo", &Edit};
FMenu Help{"&Help", &Menubar};
FMenuItem About{"&About", &Help};
FStatusBar Statusbar{this};
FLineEdit Input{"input...", this};
FButton Browse{"..", this};
FButton Apply{"&Apply", this};
FButton Quit{"&Quit", this};
};
int main (int argc, char* argv[])
{
FApplication app(argc, argv);
// Set the widget color theme
app.setColorTheme<BeeColorTheme>();
// Set the color palette theme
FTerm::setColorPaletteTheme<BeeColorPalette>();
dialogWidget dialog(&app);
FWidget::setMainWidget(&dialog);
dialog.show();
return app.exec();
}
```
After entering the source code in *theme.cpp* you can compile
the above program with gcc:
```cpp
g++ -O2 -lfinal -std=c++11 theme.cpp -o theme
```

BIN
doc/user-theme.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* 7segment.cpp - Seven-segment display * * 7segment.cpp - Seven-segment display *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -100,18 +100,19 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
Input.addCallback Input.addCallback
( (
"changed", "changed",
[] (const finalcut::FWidget*, FDataPtr data) [] (SegmentView& dialog)
{ {
auto dialog = static_cast<SegmentView*>(data); dialog.redraw();
dialog->redraw();
}, },
this std::ref(*this)
); );
Exit.addCallback Exit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }

View File

@ -1,5 +1,5 @@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Makefile.am - The Final Cut example programs # Makefile.am - FINAL CUT example programs
#---------------------------------------------------------------------- #----------------------------------------------------------------------
if ! CPPUNIT_TEST if ! CPPUNIT_TEST
@ -15,6 +15,7 @@ noinst_PROGRAMS = \
fullwidth-character \ fullwidth-character \
7segment \ 7segment \
choice \ choice \
busy \
listbox \ listbox \
listview \ listview \
checklist \ checklist \
@ -44,6 +45,7 @@ event_log_SOURCES = event-log.cpp
fullwidth_character_SOURCES = fullwidth-character.cpp fullwidth_character_SOURCES = fullwidth-character.cpp
7segment_SOURCES = 7segment.cpp 7segment_SOURCES = 7segment.cpp
choice_SOURCES = choice.cpp choice_SOURCES = choice.cpp
busy_SOURCES = busy.cpp
listbox_SOURCES = listbox.cpp listbox_SOURCES = listbox.cpp
listview_SOURCES = listview.cpp listview_SOURCES = listview.cpp
checklist_SOURCES = checklist.cpp checklist_SOURCES = checklist.cpp

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* background-color.cpp - Sets the background color palette * * background-color.cpp - Sets the background color palette *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -42,7 +42,7 @@ class Background final : public finalcut::FDialog
using FDialog::setGeometry; using FDialog::setGeometry;
// Typedef // Typedef
typedef std::tuple<uChar,uChar,uChar> RGB; typedef std::tuple<uChar, uChar, uChar> RGB;
// Constructor // Constructor
explicit Background (finalcut::FWidget* = nullptr); explicit Background (finalcut::FWidget* = nullptr);
@ -58,8 +58,8 @@ class Background final : public finalcut::FDialog
private: private:
// Callback method // Callback method
void cb_changed (const finalcut::FWidget*, const FDataPtr); void cb_changed();
void cb_choice (const finalcut::FWidget*, const FDataPtr); void cb_choice();
// Data members // Data members
finalcut::FComboBox color_choice{this}; finalcut::FComboBox color_choice{this};
@ -148,7 +148,9 @@ Background::Background (finalcut::FWidget* parent)
quit.addCallback quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
for (const auto spinbox : {&red, &green, &blue}) for (const auto spinbox : {&red, &green, &blue})
@ -156,7 +158,7 @@ Background::Background (finalcut::FWidget* parent)
spinbox->addCallback spinbox->addCallback
( (
"changed", "changed",
F_METHOD_CALLBACK (this, &Background::cb_changed) this, &Background::cb_changed
); );
} }
@ -165,7 +167,7 @@ Background::Background (finalcut::FWidget* parent)
color_choice.addCallback color_choice.addCallback
( (
signal, signal,
F_METHOD_CALLBACK (this, &Background::cb_choice) this, &Background::cb_choice
); );
} }
} }
@ -175,7 +177,7 @@ Background::~Background() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Background::cb_changed (const finalcut::FWidget*, const FDataPtr) void Background::cb_changed()
{ {
if ( ! finalcut::FTerm::canChangeColorPalette() ) if ( ! finalcut::FTerm::canChangeColorPalette() )
return; return;
@ -189,7 +191,7 @@ void Background::cb_changed (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Background::cb_choice (const finalcut::FWidget*, const FDataPtr) void Background::cb_choice()
{ {
if ( ! finalcut::FTerm::canChangeColorPalette() ) if ( ! finalcut::FTerm::canChangeColorPalette() )
return; return;
@ -217,8 +219,13 @@ void Background::cb_choice (const finalcut::FWidget*, const FDataPtr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Create the application object
finalcut::FApplication app(argc, argv); finalcut::FApplication app(argc, argv);
// Force terminal initialization without calling show()
app.initTerminal();
// The following lines require an initialized terminal
if ( finalcut::FTerm::canChangeColorPalette() ) if ( finalcut::FTerm::canChangeColorPalette() )
app.setBackgroundColor(finalcut::fc::LightMagenta); app.setBackgroundColor(finalcut::fc::LightMagenta);

129
examples/busy.cpp Normal file
View File

@ -0,0 +1,129 @@
/***********************************************************************
* busy.cpp - Shows the use of the FBusyIndicator *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 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 *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FRect;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Dialog
//----------------------------------------------------------------------
class Dialog final : public finalcut::FDialog
{
public:
explicit Dialog (FWidget* parent = nullptr);
private:
void adjustSize() override;
// Event handler
void onTimer (finalcut::FTimerEvent*) override;
// Callback method
void cb_start();
// Data members
finalcut::FSpinBox seconds{this};
finalcut::FButton start{"&Start", this};
finalcut::FButton quit{"&Quit", this};
finalcut::FBusyIndicator busy_indicator{this};
};
//----------------------------------------------------------------------
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
(
"activate",
this, &Dialog::cb_start
);
start.addCallback
(
"clicked",
this, &Dialog::cb_start
);
quit.addCallback
(
"clicked",
finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
);
}
//----------------------------------------------------------------------
void Dialog::adjustSize()
{
finalcut::FDialog::adjustSize();
int X = int((getDesktopWidth() - getWidth()) / 2);
const int Y = 5;
if ( X < 1 )
X = 1;
setPos (FPoint{X, Y}, false);
}
//----------------------------------------------------------------------
void Dialog::onTimer (finalcut::FTimerEvent*)
{
delOwnTimers();
busy_indicator.stop();
}
//----------------------------------------------------------------------
void Dialog::cb_start()
{
if ( seconds.getValue() < 1 )
return;
busy_indicator.start();
addTimer(int(seconds.getValue() * 1000));
}
//----------------------------------------------------------------------
// main part
//----------------------------------------------------------------------
int main (int argc, char* argv[])
{
finalcut::FApplication app(argc, argv);
Dialog dialog(&app);
finalcut::FWidget::setMainWidget(&dialog);
dialog.show();
return app.exec();
}

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* calculator.cpp - A simple calculator with trigonometric functions * * calculator.cpp - A simple calculator with trigonometric functions *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -119,13 +119,6 @@ class Calc final : public finalcut::FDialog
// Destructor // Destructor
~Calc() override; ~Calc() override;
// Event handlers
void onKeyPress (finalcut::FKeyEvent*) override;
void onClose (finalcut::FCloseEvent*) override;
// Callback method
void cb_buttonClicked (const finalcut::FWidget*, FDataPtr);
private: private:
// Typedef and Enumeration // Typedef and Enumeration
typedef std::function<void(lDouble&)> keyFunction; // Member function typedef std::function<void(lDouble&)> keyFunction; // Member function
@ -207,17 +200,24 @@ class Calc final : public finalcut::FDialog
void sine (lDouble&); void sine (lDouble&);
void cosine (lDouble&); void cosine (lDouble&);
void tangent (lDouble&); void tangent (lDouble&);
bool isDataEntryKey (int); bool isDataEntryKey (int) const;
bool isOperatorKey (int); bool isOperatorKey (int) const;
lDouble& getValue(); lDouble& getValue();
void setDisplay (lDouble); void setDisplay (lDouble);
void setInfixOperator (char); void setInfixOperator (char);
void clearInfixOperator(); void clearInfixOperator();
void calcInfixOperator(); void calcInfixOperator();
void adjustSize() override; void adjustSize() override;
const wchar_t* getButtonText (const std::size_t); const wchar_t* getButtonText (const std::size_t) const;
void mapKeyFunctions(); void mapKeyFunctions();
// Event handlers
void onKeyPress (finalcut::FKeyEvent*) override;
void onClose (finalcut::FCloseEvent*) override;
// Callback method
void cb_buttonClicked (Calc::button);
// Data members // Data members
bool error{false}; bool error{false};
bool arcus_mode{false}; bool arcus_mode{false};
@ -230,7 +230,7 @@ class Calc final : public finalcut::FDialog
char infix_operator{'\0'}; char infix_operator{'\0'};
char last_infix_operator{'\0'}; char last_infix_operator{'\0'};
finalcut::FString input{""}; finalcut::FString input{""};
std::size_t button_no[Calc::NUM_OF_BUTTONS]{}; button button_no[Calc::NUM_OF_BUTTONS]{};
struct stack_data struct stack_data
{ {
@ -257,7 +257,7 @@ Calc::Calc (FWidget* parent)
clearInfixOperator(); clearInfixOperator();
std::setlocale(LC_NUMERIC, "C"); std::setlocale(LC_NUMERIC, "C");
for (std::size_t key{0}; key < Calc::NUM_OF_BUTTONS; key++) for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
{ {
auto btn = std::make_shared<Button>(this); auto btn = std::make_shared<Button>(this);
button_no[key] = key; button_no[key] = key;
@ -284,8 +284,8 @@ Calc::Calc (FWidget* parent)
btn->addCallback btn->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Calc::cb_buttonClicked), this, &Calc::cb_buttonClicked,
&button_no[key] button_no[key]
); );
calculator_buttons[button(key)] = btn; calculator_buttons[button(key)] = btn;
@ -364,10 +364,9 @@ void Calc::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::cb_buttonClicked (const finalcut::FWidget*, FDataPtr data) void Calc::cb_buttonClicked (Calc::button key)
{ {
lDouble& x = getValue(); lDouble& x = getValue();
const Calc::button& key = *(static_cast<Calc::button*>(data));
// Call the key function // Call the key function
key_map[key](x); key_map[key](x);
@ -941,7 +940,7 @@ void Calc::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool Calc::isDataEntryKey (int key) bool Calc::isDataEntryKey (int key) const
{ {
// Test if key is in {'.', '0'..'9'} // Test if key is in {'.', '0'..'9'}
const int data_entry_keys[] = const int data_entry_keys[] =
@ -968,7 +967,7 @@ bool Calc::isDataEntryKey (int key)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool Calc::isOperatorKey(int key) bool Calc::isOperatorKey(int key) const
{ {
// Test if key is in {'*', '/', '+', '-', '^', '='} // Test if key is in {'*', '/', '+', '-', '^', '='}
const int operators[] = const int operators[] =
@ -1091,7 +1090,7 @@ void Calc::adjustSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const wchar_t* Calc::getButtonText (const std::size_t key) const wchar_t* Calc::getButtonText (const std::size_t key) const
{ {
static const wchar_t* const button_text[Calc::NUM_OF_BUTTONS] = static const wchar_t* const button_text[Calc::NUM_OF_BUTTONS] =
{ {

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* checklist.cpp - Example for FListView widget with checkboxes * * checklist.cpp - Example for FListView widget with checkboxes *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -64,7 +64,7 @@ class CheckList final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
void cb_showList (const finalcut::FWidget*, const FDataPtr); void cb_showList();
// Data members // Data members
finalcut::FListView listView{this}; finalcut::FListView listView{this};
@ -110,7 +110,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
listView.addCallback listView.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &CheckList::cb_showList) this, &CheckList::cb_showList
); );
} }
@ -168,7 +168,7 @@ void CheckList::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void CheckList::cb_showList (const finalcut::FWidget*, const FDataPtr) void CheckList::cb_showList()
{ {
auto iter = listView.beginOfList(); auto iter = listView.beginOfList();
finalcut::FString shopping_list{}; finalcut::FString shopping_list{};

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* choice.cpp - FButtonGroup with scroll view * * choice.cpp - FButtonGroup with scroll view *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -31,17 +31,16 @@ using finalcut::FSize;
typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr; typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr;
// Function prototypes // Function prototypes
void cb_quit (const finalcut::FWidget*, FDataPtr); void cb_quit (finalcut::FDialog&);
void populateChoice (std::vector<FRadioButtonPtr>&, finalcut::FButtonGroup&); void populateChoice (std::vector<FRadioButtonPtr>&, finalcut::FButtonGroup&);
void preset (std::vector<FRadioButtonPtr>&); void preset (std::vector<FRadioButtonPtr>&);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Callback functions // Callback functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (const finalcut::FWidget*, FDataPtr data) void cb_quit (finalcut::FDialog& dlg)
{ {
auto dlg = static_cast<finalcut::FDialog*>(data); dlg.close();
dlg->close();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -141,7 +140,7 @@ int main (int argc, char* argv[])
( (
"clicked", "clicked",
&cb_quit, &cb_quit,
&dgl std::ref(dgl)
); );
// Show the dialog // Show the dialog

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* dialog.cpp - A FDialog example * * dialog.cpp - A FDialog example *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -26,15 +26,14 @@ using finalcut::FPoint;
using finalcut::FSize; using finalcut::FSize;
// function prototype // function prototype
void cb_quit (const finalcut::FWidget*, FDataPtr); void cb_quit (const finalcut::FApplication&);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// callback function // callback function
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (const finalcut::FWidget*, FDataPtr data) void cb_quit (const finalcut::FApplication& app)
{ {
auto& app = *(static_cast<finalcut::FApplication*>(data));
app.quit(); app.quit();
} }
@ -77,7 +76,7 @@ int main (int argc, char* argv[])
( (
"clicked", "clicked",
&cb_quit, &cb_quit,
&app std::ref(app)
); );
// Set dialog object as main widget // Set dialog object as main widget

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* event-log.cpp - Logs events in a dialog box * * event-log.cpp - Logs events in a dialog box *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -58,7 +58,7 @@ class EventDialog final : public finalcut::FDialog
private: private:
// Methods // Methods
finalcut::FString getMouseButtonName (int); finalcut::FString getMouseButtonName (int) const;
void logMouseEvent ( const finalcut::FString& void logMouseEvent ( const finalcut::FString&
, const finalcut::FMouseEvent& ); , const finalcut::FMouseEvent& );
@ -103,7 +103,7 @@ EventDialog::~EventDialog() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
finalcut::FString EventDialog::getMouseButtonName (int btn_state) finalcut::FString EventDialog::getMouseButtonName (int btn_state) const
{ {
switch ( btn_state ) switch ( btn_state )
{ {

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fullwidth-letter.cpp - Demonstrates use of full-width characters * * fullwidth-letter.cpp - Demonstrates use of full-width characters *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -105,16 +105,14 @@ int main (int argc, char* argv[])
// Callback lambda expressions // Callback lambda expressions
auto cb_exit = \ auto cb_exit = \
[] (const finalcut::FWidget*, FDataPtr data) [] (const finalcut::FApplication& a)
{ {
auto a = static_cast<finalcut::FApplication*>(data); a.quit();
a->quit();
}; };
auto cb_tooltip = \ auto cb_tooltip = \
[] (const finalcut::FWidget*, FDataPtr data) [] (finalcut::FApplication* a)
{ {
auto a = static_cast<finalcut::FApplication*>(data);
finalcut::FToolTip tooltip(a); finalcut::FToolTip tooltip(a);
tooltip.setText (full("A tooltip with\ncharacters\n" tooltip.setText (full("A tooltip with\ncharacters\n"
"in full-width\nfor 3 seconds")); "in full-width\nfor 3 seconds"));
@ -123,9 +121,9 @@ int main (int argc, char* argv[])
}; };
// Connect the signals with the callback lambda expressions // Connect the signals with the callback lambda expressions
btn.addCallback ("clicked", cb_exit, &app); btn.addCallback ("clicked", cb_exit, std::ref(app));
Exit.addCallback ("clicked", cb_exit, &app); Exit.addCallback ("clicked", cb_exit, std::ref(app));
Quit.addCallback ("clicked", cb_exit, &app); Quit.addCallback ("clicked", cb_exit, std::ref(app));
key_F1.addCallback ("activate", cb_tooltip, &app); key_F1.addCallback ("activate", cb_tooltip, &app);
// Set dialog object as main widget // Set dialog object as main widget

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* hello.cpp - A simple hello world program * * hello.cpp - A simple hello world program *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* input-dialog.cpp - An input field example * * input-dialog.cpp - An input field example *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -26,33 +26,31 @@ using finalcut::FPoint;
using finalcut::FSize; using finalcut::FSize;
// function prototypes // function prototypes
void cb_quit (const finalcut::FWidget*, FDataPtr); void cb_quit (const finalcut::FApplication&);
void cb_publish (finalcut::FWidget*, FDataPtr); void cb_publish (const finalcut::FCheckBox&, finalcut::FCheckBox&);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// callback functions // callback functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cb_quit (const finalcut::FWidget*, FDataPtr data) void cb_quit (const finalcut::FApplication& app)
{ {
auto app = static_cast<finalcut::FApplication*>(data); app.quit();
app->quit();
} }
void cb_publish (finalcut::FWidget* widget, FDataPtr data) //----------------------------------------------------------------------
void cb_publish ( const finalcut::FCheckBox& cbox1
, finalcut::FCheckBox& cbox2 )
{ {
auto cbox1 = static_cast<finalcut::FCheckBox*>(widget); if ( cbox1.isChecked() )
auto cbox2 = static_cast<finalcut::FCheckBox*>(data); cbox2.setEnable();
if ( cbox1->isChecked() )
cbox2->setEnable();
else else
{ {
cbox2->unsetChecked(); cbox2.unsetChecked();
cbox2->setDisable(); cbox2.setDisable();
} }
cbox2->redraw(); cbox2.redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -124,7 +122,8 @@ int main (int argc, char* argv[])
( (
"clicked", "clicked",
&cb_publish, &cb_publish,
&check2 std::ref(check1),
std::ref(check2)
); );
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
@ -132,7 +131,7 @@ int main (int argc, char* argv[])
( (
"clicked", "clicked",
&cb_quit, &cb_quit,
&app std::ref(app)
); );
// Set dialog object as main widget // Set dialog object as main widget

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* keyboard.cpp - Shows typed-in key name * * keyboard.cpp - Shows typed-in key name *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -95,6 +95,9 @@ int main (int argc, char* argv[])
{ {
// Create the application object // Create the application object
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(finalcut::fc::Default); app.setForegroundColor(finalcut::fc::Default);
app.setBackgroundColor(finalcut::fc::Default); app.setBackgroundColor(finalcut::fc::Default);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* listbox.cpp - Example for using a FListBox widget * * listbox.cpp - Example for using a FListBox widget *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -157,7 +157,9 @@ Listbox::Listbox (FWidget* parent)
Quit.addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* listview.cpp - Example for using a multi-column FListView widget * * listview.cpp - Example for using a multi-column FListView widget *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -59,7 +59,7 @@ class Listview final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
void cb_showInMessagebox (const finalcut::FWidget*, const FDataPtr); void cb_showInMessagebox();
// Data members // Data members
finalcut::FListView listView{this}; finalcut::FListView listView{this};
@ -111,13 +111,15 @@ Listview::Listview (finalcut::FWidget* parent)
Quit.addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
listView.addCallback listView.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Listview::cb_showInMessagebox) this, &Listview::cb_showInMessagebox
); );
} }
@ -187,7 +189,7 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Listview::cb_showInMessagebox (const finalcut::FWidget*, const FDataPtr) void Listview::cb_showInMessagebox()
{ {
const auto& item = listView.getCurrentItem(); const auto& item = listView.getCurrentItem();
finalcut::FMessageBox info ( "Weather in " + item->getText(1) finalcut::FMessageBox info ( "Weather in " + item->getText(1)

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* mandelbrot.cpp - Shows a ASCII based Mandelbrot set * * mandelbrot.cpp - Shows a ASCII based Mandelbrot set *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* menu.cpp - A menu example * * menu.cpp - A menu example *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -61,7 +61,7 @@ class Menu final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
void cb_message (finalcut::FWidget*, const FDataPtr); void cb_message (const finalcut::FMenuItem*);
// Data members // Data members
finalcut::FString line{13, fc::BoxDrawingsHorizontal}; finalcut::FString line{13, fc::BoxDrawingsHorizontal};
@ -183,7 +183,9 @@ void Menu::configureFileMenuItems()
Quit.addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }
@ -275,7 +277,8 @@ void Menu::defaultCallback (const finalcut::FMenuList* mb)
item->addCallback item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Menu::cb_message) this, &Menu::cb_message,
item
); );
// Call sub-menu // Call sub-menu
@ -302,9 +305,8 @@ void Menu::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::cb_message (finalcut::FWidget* widget, const FDataPtr) void Menu::cb_message (const finalcut::FMenuItem* menuitem)
{ {
const auto& menuitem = static_cast<finalcut::FMenuItem*>(widget);
auto text = menuitem->getText(); auto text = menuitem->getText();
text = text.replace('&', ""); text = text.replace('&', "");
finalcut::FMessageBox::info ( this finalcut::FMessageBox::info ( this

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* mouse.cpp - A small mouse-controlled drawing program * * mouse.cpp - A small mouse-controlled drawing program *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -49,8 +49,8 @@ class ColorChooser final : public finalcut::FWidget
ColorChooser& operator = (const ColorChooser&) = delete; ColorChooser& operator = (const ColorChooser&) = delete;
// Accessors // Accessors
FColor getForeground(); FColor getForeground() const;
FColor getBackground(); FColor getBackground() const;
private: private:
// Mutator // Mutator
@ -78,16 +78,6 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
setFixedSize (FSize{8, 12}); setFixedSize (FSize{8, 12});
unsetFocusable(); unsetFocusable();
if ( parent )
{
const FColor fg = parent->getForegroundColor();
const FColor bg = parent->getBackgroundColor();
FWidget::setForegroundColor(fg);
FWidget::setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label // Text label
headline.setGeometry (FPoint{1, 1}, FSize{8, 1}); headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis(); headline.setEmphasis();
@ -100,13 +90,13 @@ ColorChooser::~ColorChooser()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FColor ColorChooser::getForeground() inline FColor ColorChooser::getForeground() const
{ {
return fg_color; return fg_color;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FColor ColorChooser::getBackground() inline FColor ColorChooser::getBackground() const
{ {
return bg_color; return bg_color;
} }
@ -122,6 +112,8 @@ void ColorChooser::setSize (const FSize& size, bool adjust)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ColorChooser::draw() void ColorChooser::draw()
{ {
useParentWidgetColor();
headline.setBackgroundColor(getBackgroundColor());
setColor(); setColor();
drawBorder(); drawBorder();
@ -200,7 +192,7 @@ class Brushes final : public finalcut::FWidget
Brushes& operator = (const Brushes&) = delete; Brushes& operator = (const Brushes&) = delete;
// Accessor // Accessor
wchar_t getBrush(); wchar_t getBrush() const;
// Mutators // Mutators
void setForeground (FColor); void setForeground (FColor);
@ -232,16 +224,6 @@ Brushes::Brushes (finalcut::FWidget* parent)
setFixedSize (FSize{8, 4}); setFixedSize (FSize{8, 4});
unsetFocusable(); unsetFocusable();
if ( parent )
{
const FColor fg = parent->getForegroundColor();
const FColor bg = parent->getBackgroundColor();
FWidget::setForegroundColor(fg);
FWidget::setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label // Text label
headline.setGeometry(FPoint{1, 1}, FSize{8, 1}); headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis(); headline.setEmphasis();
@ -265,6 +247,8 @@ void Brushes::setSize (const FSize& size, bool adjust)
void Brushes::draw() void Brushes::draw()
{ {
int pos{0}; int pos{0};
useParentWidgetColor();
headline.setBackgroundColor(getBackgroundColor());
setColor(); setColor();
drawBorder(); drawBorder();
print() << FPoint{2, 3} print() << FPoint{2, 3}
@ -309,7 +293,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline wchar_t Brushes::getBrush() inline wchar_t Brushes::getBrush() const
{ {
return brush; return brush;
} }
@ -361,6 +345,7 @@ class MouseDraw final : public finalcut::FDialog
void draw() override; void draw() override;
void drawBrush (int, int, bool = false); void drawBrush (int, int, bool = false);
void drawCanvas(); void drawCanvas();
void createCanvas();
void adjustSize() override; void adjustSize() override;
// Event handler // Event handler
@ -368,7 +353,7 @@ class MouseDraw final : public finalcut::FDialog
void onMouseMove (finalcut::FMouseEvent*) override; void onMouseMove (finalcut::FMouseEvent*) override;
// Callback methods // Callback methods
void cb_colorChanged (const finalcut::FWidget*, const FDataPtr); void cb_colorChanged();
// Data members // Data members
FTermArea* canvas{nullptr}; FTermArea* canvas{nullptr};
@ -386,14 +371,10 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
c_chooser.addCallback c_chooser.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged) this, &MouseDraw::cb_colorChanged
); );
brush.setPos (FPoint{1, 12}); brush.setPos (FPoint{1, 12});
FSize no_shadow{0, 0};
finalcut::FRect scroll_geometry{0, 0, 1, 1};
createArea (scroll_geometry, no_shadow, canvas);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -407,6 +388,10 @@ void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust)
const std::size_t w = s.getWidth(); const std::size_t w = s.getWidth();
const std::size_t h = s.getHeight(); const std::size_t h = s.getHeight();
const finalcut::FRect scroll_geometry (FPoint{0, 0}, FSize{w - 11, h - 3}); const finalcut::FRect scroll_geometry (FPoint{0, 0}, FSize{w - 11, h - 3});
if ( ! canvas )
return;
const FSize no_shadow{0, 0}; const FSize no_shadow{0, 0};
const int old_w = canvas->width; const int old_w = canvas->width;
const int old_h = canvas->height; const int old_h = canvas->height;
@ -504,6 +489,10 @@ void MouseDraw::drawCanvas()
if ( ! hasPrintArea() ) if ( ! hasPrintArea() )
finalcut::FVTerm::getPrintArea(); finalcut::FVTerm::getPrintArea();
// Create canvas after initializing the desktop and color theme
if ( ! canvas )
createCanvas();
if ( ! (hasPrintArea() && canvas) ) if ( ! (hasPrintArea() && canvas) )
return; return;
@ -534,6 +523,15 @@ void MouseDraw::drawCanvas()
printarea->has_changes = true; printarea->has_changes = true;
} }
//----------------------------------------------------------------------
void MouseDraw::createCanvas()
{
FSize no_shadow{0, 0};
finalcut::FRect scroll_geometry{0, 0, 1, 1};
createArea (scroll_geometry, no_shadow, canvas);
adjustSize();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::adjustSize() void MouseDraw::adjustSize()
{ {
@ -574,7 +572,7 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::cb_colorChanged (const finalcut::FWidget*, const FDataPtr) void MouseDraw::cb_colorChanged()
{ {
brush.setForeground (c_chooser.getForeground()); brush.setForeground (c_chooser.getForeground());
brush.setBackground (c_chooser.getBackground()); brush.setBackground (c_chooser.getBackground());

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* opti-move.cpp - Tests the cursor movement optimization * * opti-move.cpp - Tests the cursor movement optimization *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <iomanip> #include <iomanip>
#include <memory>
#include <string> #include <string>
#include <final/final.h> #include <final/final.h>
@ -133,62 +134,107 @@ void move (int xold, int yold, int xnew, int ynew)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class DirectLogger : public finalcut::FLog class DirectLogger final : public finalcut::FLog
{ {
public: public:
// Constructor
DirectLogger();
// Destructor
~DirectLogger() override;
void info (const std::string& entry) override void info (const std::string& entry) override
{ {
output << entry << "\r" << std::endl; output << entry << "\r" << std::endl;
} }
void warn (const std::string&) override void warn (const std::string&) override
{ } {
// An implementation is not required in this context
}
void error (const std::string&) override void error (const std::string&) override
{ } {
// An implementation is not required in this context
}
void debug (const std::string&) override void debug (const std::string&) override
{ } {
// An implementation is not required in this context
}
void flush() override
{
output.flush();
}
void setOutputStream (const std::ostream& os) override void setOutputStream (const std::ostream& os) override
{ output.rdbuf(os.rdbuf()); } { output.rdbuf(os.rdbuf()); }
void setLineEnding (LineEnding) override void setLineEnding (LineEnding) override
{ } {
// An implementation is not required in this context
}
void enableTimestamp() override void enableTimestamp() override
{ } {
// An implementation is not required in this context
}
void disableTimestamp() override void disableTimestamp() override
{ } {
// An implementation is not required in this context
}
private: private:
// Data member // Data member
std::ostream output{std::cerr.rdbuf()}; std::ostream output{std::cerr.rdbuf()};
}; };
//----------------------------------------------------------------------
DirectLogger::DirectLogger() // constructor
{ }
//----------------------------------------------------------------------
DirectLogger::~DirectLogger() // destructor
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// main part // main part
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Disable mouse
finalcut::FStartOptions::getFStartOptions().mouse_support = false;
// Create the application object // Create the application object
finalcut::FApplication TermApp{argc, argv}; finalcut::FApplication term_app{argc, argv};
// Force terminal initialization without calling show()
term_app.initTerminal();
if ( finalcut::FApplication::isQuit() )
return 0;
// Pointer to the global virtual terminal object // Pointer to the global virtual terminal object
app = &TermApp; app = &term_app;
// Get screen dimension // Get screen dimension
int xmax = int(TermApp.getDesktopWidth() - 1); int xmax = int(term_app.getDesktopWidth() - 1);
int ymax = int(TermApp.getDesktopHeight() - 1); int ymax = int(term_app.getDesktopHeight() - 1);
finalcut::FString line{std::size_t(xmax) + 1, '-'}; finalcut::FString line{std::size_t(xmax) + 1, '-'};
// Place the cursor in the upper left corner // Place the cursor in the upper left corner
TermApp.setTermXY(0, 0); term_app.setTermXY(0, 0);
// Reset all terminal attributes // Reset all terminal attributes
TermApp.setNormal(); term_app.setNormal();
// Clear the screen // Clear the screen
TermApp.clearArea(); term_app.clearArea();
// Show the determined terminal name and text resolution // Show the determined terminal name and text resolution
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n"; std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
@ -226,12 +272,12 @@ int main (int argc, char* argv[])
std::cout << "\r" << line << std::flush; std::cout << "\r" << line << std::flush;
// Generation of a logger in a shared_ptr via a pointer // Generation of a logger in a shared_ptr via a pointer
finalcut::FApplication::setLog(std::make_shared<DirectLogger>()); finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
// Get the shared_ptr with the base class
std::shared_ptr<finalcut::FLog> log = finalcut::FApplication::getLog();
const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove(); const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove();
finalcut::printDurations(opti_move); finalcut::printDurations(opti_move);
// Waiting for keypress // Waiting for keypress
keyPressed(); keyPressed();
app = nullptr; // End of TermApp object scope app = nullptr; // End of term_app object scope
return 0;
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* rotozoomer.cpp - Rotozoomer effect demo * * rotozoomer.cpp - Rotozoomer effect demo *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -28,7 +28,10 @@
#include <final/final.h> #include <final/final.h>
namespace fc = finalcut::fc; namespace fc = finalcut::fc;
using namespace std::chrono; using std::chrono::duration_cast;
using std::chrono::milliseconds;
using std::chrono::system_clock;
using std::chrono::time_point;
using finalcut::FPoint; using finalcut::FPoint;
using finalcut::FSize; using finalcut::FSize;
@ -52,7 +55,7 @@ class RotoZoomer final : public finalcut::FDialog
~RotoZoomer() override; ~RotoZoomer() override;
// Accessors // Accessors
finalcut::FString getReport(); finalcut::FString getReport() const;
// Event handlers // Event handlers
void onShow (finalcut::FShowEvent*) override; void onShow (finalcut::FShowEvent*) override;
@ -187,7 +190,7 @@ void RotoZoomer::generateReport()
dimension_str << getDesktopWidth() dimension_str << getDesktopWidth()
<< "x" << getDesktopHeight(); << "x" << getDesktopHeight();
int elapsed_ms = int(duration_cast<milliseconds>(end - start).count()); int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
time_str << double(elapsed_ms) / 1000 << "ms"; time_str << double(elapsed_ms) / 1000 << "s";
fps_str << double(loops) * 1000.0 / double(elapsed_ms); fps_str << double(loops) * 1000.0 / double(elapsed_ms);
rep << finalcut::FString{55, '-'} << "\n" rep << finalcut::FString{55, '-'} << "\n"
@ -202,7 +205,7 @@ void RotoZoomer::generateReport()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline finalcut::FString RotoZoomer::getReport() inline finalcut::FString RotoZoomer::getReport() const
{ {
return report; return report;
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* scrollview.cpp - Shows client widgets in a scroll area * * scrollview.cpp - Shows client widgets in a scroll area *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -54,10 +54,10 @@ class Scrollview final : public finalcut::FScrollView
void draw() override; void draw() override;
// Callback methods // Callback methods
void cb_goEast (const finalcut::FWidget*, const FDataPtr); void cb_goEast();
void cb_goSouth (const finalcut::FWidget*, const FDataPtr); void cb_goSouth();
void cb_goWest (const finalcut::FWidget*, const FDataPtr); void cb_goWest();
void cb_goNorth (const finalcut::FWidget*, const FDataPtr); void cb_goNorth();
// Data members // Data members
wchar_t pointer_right{fc::BlackRightPointingPointer}; wchar_t pointer_right{fc::BlackRightPointingPointer};
@ -88,25 +88,25 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
go_east.addCallback go_east.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_goEast) this, &Scrollview::cb_goEast
); );
go_south.addCallback go_south.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_goSouth) this, &Scrollview::cb_goSouth
); );
go_west.addCallback go_west.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_goWest) this, &Scrollview::cb_goWest
); );
go_north.addCallback go_north.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollview::cb_goNorth) this, &Scrollview::cb_goNorth
); );
} }
@ -150,7 +150,7 @@ void Scrollview::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_goEast (const finalcut::FWidget*, const FDataPtr) void Scrollview::cb_goEast()
{ {
scrollToX (int(getScrollWidth() - getViewportWidth()) + 1); scrollToX (int(getScrollWidth() - getViewportWidth()) + 1);
go_south.setFocus(); go_south.setFocus();
@ -159,7 +159,7 @@ void Scrollview::cb_goEast (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_goSouth (const finalcut::FWidget*, const FDataPtr) void Scrollview::cb_goSouth()
{ {
scrollToY (int(getScrollHeight() - getViewportHeight()) + 1); scrollToY (int(getScrollHeight() - getViewportHeight()) + 1);
go_west.setFocus(); go_west.setFocus();
@ -168,7 +168,7 @@ void Scrollview::cb_goSouth (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_goWest (const finalcut::FWidget*, const FDataPtr) void Scrollview::cb_goWest()
{ {
scrollToX (1); scrollToX (1);
go_north.setFocus(); go_north.setFocus();
@ -177,7 +177,7 @@ void Scrollview::cb_goWest (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::cb_goNorth (const finalcut::FWidget*, const FDataPtr) void Scrollview::cb_goNorth()
{ {
scrollToY (1); scrollToY (1);
go_east.setFocus(); go_east.setFocus();
@ -203,7 +203,7 @@ class Scrollviewdemo final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
void cb_quit (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr); void cb_quit();
// Data members // Data members
Scrollview sview{this}; Scrollview sview{this};
@ -230,7 +230,8 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
quit_btn.addCallback quit_btn.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &Scrollviewdemo::cb_quit) this,
&Scrollviewdemo::cb_quit
); );
// Text label // Text label
@ -244,7 +245,7 @@ Scrollviewdemo::~Scrollviewdemo()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollviewdemo::cb_quit (const finalcut::FWidget*, const FDataPtr) void Scrollviewdemo::cb_quit()
{ {
close(); close();
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* string-operations.cpp - Demonstrates the functionality of FString * * string-operations.cpp - Demonstrates the functionality of FString *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* term-attributes.cpp - Test the video attributes of the terminal * * term-attributes.cpp - Test the video attributes of the terminal *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -50,7 +50,7 @@ class AttribDlg final : public finalcut::FDialog
AttribDlg& operator = (const AttribDlg&) = delete; AttribDlg& operator = (const AttribDlg&) = delete;
// Methods // Methods
FColor getBGColor(); FColor getBGColor() const;
// Event handlers // Event handlers
void onKeyPress (finalcut::FKeyEvent*) override; void onKeyPress (finalcut::FKeyEvent*) override;
@ -58,15 +58,19 @@ class AttribDlg final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback methods // Callback methods
void cb_next (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr); void cb_next();
void cb_back (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr); void cb_back();
private: private:
// Constants
static constexpr FColor UNDEFINED = static_cast<FColor>(-2);
// Method // Method
void adjustSize() override; void adjustSize() override;
void draw() override;
// Data members // Data members
FColor bgcolor{getColorTheme()->label_bg}; FColor bgcolor{UNDEFINED};
finalcut::FButton next_button{"&Next >", this}; finalcut::FButton next_button{"&Next >", this};
finalcut::FButton back_button{"< &Back", this}; finalcut::FButton back_button{"< &Back", this};
}; };
@ -75,10 +79,6 @@ class AttribDlg final : public finalcut::FDialog
AttribDlg::AttribDlg (finalcut::FWidget* parent) AttribDlg::AttribDlg (finalcut::FWidget* parent)
: finalcut::FDialog{parent} : finalcut::FDialog{parent}
{ {
FDialog::setText ( "A terminal attributes test ("
+ finalcut::FString{finalcut::FTerm::getTermType()}
+ ")");
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4} next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
, FSize{10, 1} ); , FSize{10, 1} );
next_button.addAccelerator (fc::Fkey_right); next_button.addAccelerator (fc::Fkey_right);
@ -90,13 +90,13 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
next_button.addCallback next_button.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_next) this, &AttribDlg::cb_next
); );
back_button.addCallback back_button.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &AttribDlg::cb_back) this, &AttribDlg::cb_back
); );
} }
@ -105,7 +105,7 @@ AttribDlg::~AttribDlg()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FColor AttribDlg::getBGColor() FColor AttribDlg::getBGColor() const
{ {
return bgcolor; return bgcolor;
} }
@ -143,7 +143,7 @@ void AttribDlg::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::cb_next (const finalcut::FWidget*, const FDataPtr) void AttribDlg::cb_next()
{ {
if ( finalcut::FTerm::isMonochron() ) if ( finalcut::FTerm::isMonochron() )
return; return;
@ -159,7 +159,7 @@ void AttribDlg::cb_next (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::cb_back (const finalcut::FWidget*, const FDataPtr) void AttribDlg::cb_back()
{ {
if ( finalcut::FTerm::isMonochron() ) if ( finalcut::FTerm::isMonochron() )
return; return;
@ -194,6 +194,26 @@ void AttribDlg::adjustSize()
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
//----------------------------------------------------------------------
void AttribDlg::draw()
{
if ( bgcolor == UNDEFINED )
{
// Get the color after initializing the color theme in show()
if ( finalcut::FTerm::isMonochron() )
bgcolor = fc::Default;
else
bgcolor = getColorTheme()->label_bg;
// Get the terminal type after the terminal detection in show()
FDialog::setText ( "A terminal attributes test ("
+ finalcut::FString{finalcut::FTerm::getTermType()}
+ ")");
}
FDialog::draw();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class AttribDemo // class AttribDemo
@ -238,18 +258,13 @@ class AttribDemo final : public finalcut::FWidget
void draw() override; void draw() override;
// Data member // Data member
FColor last_color{FColor(finalcut::FTerm::getMaxColor())}; FColor last_color{1};
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
AttribDemo::AttribDemo (finalcut::FWidget* parent) AttribDemo::AttribDemo (finalcut::FWidget* parent)
: finalcut::FWidget{parent} : finalcut::FWidget{parent}
{ {
if ( finalcut::FTerm::isMonochron() )
last_color = 1;
else if ( last_color > 16 )
last_color = 16;
unsetFocusable(); unsetFocusable();
} }
@ -417,8 +432,15 @@ void AttribDemo::printProtected()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::draw() void AttribDemo::draw()
{ {
// test alternate character set
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
last_color = FColor(finalcut::FTerm::getMaxColor());
if ( finalcut::FTerm::isMonochron() )
last_color = 1;
else if ( last_color > 16 )
last_color = 16;
// test alternate character set
printAltCharset(); printAltCharset();
const std::vector<std::function<void()> > effect const std::vector<std::function<void()> > effect

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* termcap.cpp - Show the used termcap variables * * termcap.cpp - Show the used termcap variables *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -32,7 +32,7 @@ namespace fc = finalcut::fc;
void tcapBoolean (const std::string&, bool); void tcapBoolean (const std::string&, bool);
void tcapNumeric (const std::string&, int); void tcapNumeric (const std::string&, int);
void tcapString (const std::string&, const char[]); void tcapString (const std::string&, const char[]);
void debug (finalcut::FApplication&); void debug (const finalcut::FApplication&);
void booleans(); void booleans();
void numeric(); void numeric();
void string(); void string();
@ -207,7 +207,7 @@ void tcapString (const std::string& name, const char cap_str[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if DEBUG #if DEBUG
void debug (finalcut::FApplication& TermApp) void debug (const finalcut::FApplication& TermApp)
{ {
const auto& fterm = TermApp.getFTerm(); const auto& fterm = TermApp.getFTerm();
auto& debug_data = fterm.getFTermDebugData(); auto& debug_data = fterm.getFTermDebugData();
@ -256,6 +256,8 @@ void booleans()
, finalcut::FTermcap::automatic_right_margin ); , finalcut::FTermcap::automatic_right_margin );
tcapBoolean ( "eat_nl_glitch" tcapBoolean ( "eat_nl_glitch"
, finalcut::FTermcap::eat_nl_glitch ); , finalcut::FTermcap::eat_nl_glitch );
tcapBoolean ( "has_ansi_escape_sequences"
, finalcut::FTermcap::has_ansi_escape_sequences );
tcapBoolean ( "ansi_default_color" tcapBoolean ( "ansi_default_color"
, finalcut::FTermcap::ansi_default_color ); , finalcut::FTermcap::ansi_default_color );
tcapBoolean ( "osc_support" tcapBoolean ( "osc_support"
@ -296,15 +298,30 @@ void string()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
const bool disable_alt_screen{true}; // Disabling the switch to the alternative screen
finalcut::FApplication TermApp {argc, argv, disable_alt_screen}; finalcut::FTerm::useAlternateScreen(false);
// Disable color palette changes and terminal data requests
auto& start_options = finalcut::FStartOptions::getFStartOptions();
start_options.color_change = false;
start_options.terminal_data_request = false;
// Create the application object as root widget
finalcut::FApplication term_app {argc, argv};
// Force terminal initialization without calling show()
term_app.initTerminal();
if ( finalcut::FApplication::isQuit() )
return 0;
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n"; std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n"; std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
debug (TermApp); debug (term_app);
booleans(); booleans();
numeric(); numeric();
string(); string();
return 0;
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* timer.cpp - Using timer events * * timer.cpp - Using timer events *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -35,7 +35,7 @@ class Timer final : public finalcut::FWidget
// Constructor // Constructor
explicit Timer (finalcut::FWidget* = nullptr); explicit Timer (finalcut::FWidget* = nullptr);
protected: private:
// Method // Method
void draw() override; void draw() override;
@ -101,6 +101,9 @@ int main (int argc, char* argv[])
{ {
// Create the application object // Create the application object
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(fc::Default); app.setForegroundColor(fc::Default);
app.setBackgroundColor(fc::Default); app.setBackgroundColor(fc::Default);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* transparent.cpp - Demonstrates transparent windows * * transparent.cpp - Demonstrates transparent windows *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* treeview.cpp - Example of a FListView widget with a tree hierarchy * * treeview.cpp - Example of a FListView widget with a tree hierarchy *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -386,7 +386,9 @@ Treeview::Treeview (finalcut::FWidget* parent)
Quit.addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
initialized = true; initialized = true;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* ui.cpp - Example of a user interface * * ui.cpp - Example of a user interface *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2019 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -63,9 +63,9 @@ class ProgressDialog final : public finalcut::FDialog
void onTimer (finalcut::FTimerEvent*) override; void onTimer (finalcut::FTimerEvent*) override;
// Callback methods // Callback methods
void cb_reset_bar (const finalcut::FWidget*, const FDataPtr); void cb_reset_bar();
void cb_more_bar (const finalcut::FWidget*, const FDataPtr); void cb_more_bar();
void cb_exit_bar (const finalcut::FWidget*, const FDataPtr); void cb_exit_bar();
// Data members // Data members
finalcut::FProgressbar progressBar{this}; finalcut::FProgressbar progressBar{this};
@ -103,30 +103,29 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false); progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
//progressBar.setPercentage(78); //progressBar.setPercentage(78);
using namespace std::placeholders;
reset.addCallback reset.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_reset_bar) this, &ProgressDialog::cb_reset_bar
); );
more.addCallback more.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_more_bar) this, &ProgressDialog::cb_more_bar
); );
quit.addCallback quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &ProgressDialog::cb_exit_bar) this, &ProgressDialog::cb_exit_bar
); );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
ProgressDialog::~ProgressDialog() // destructor ProgressDialog::~ProgressDialog() // destructor
{ {
delOwnTimer(); delOwnTimers();
delCallback(&quit); delCallback(&quit);
delCallback(&more); delCallback(&more);
delCallback(&reset); delCallback(&reset);
@ -149,7 +148,7 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
if ( p != 100 ) if ( p != 100 )
return; return;
delOwnTimer(); delOwnTimers();
activateWindow(); activateWindow();
raiseWindow(); raiseWindow();
reset.setEnable(); reset.setEnable();
@ -166,13 +165,13 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ProgressDialog::cb_reset_bar (const finalcut::FWidget*, const FDataPtr) void ProgressDialog::cb_reset_bar()
{ {
progressBar.reset(); progressBar.reset();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ProgressDialog::cb_more_bar (const finalcut::FWidget*, const FDataPtr) void ProgressDialog::cb_more_bar()
{ {
auto p = progressBar.getPercentage(); auto p = progressBar.getPercentage();
p++; p++;
@ -180,7 +179,7 @@ void ProgressDialog::cb_more_bar (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ProgressDialog::cb_exit_bar (const finalcut::FWidget*, const FDataPtr) void ProgressDialog::cb_exit_bar()
{ {
close(); close();
} }
@ -293,22 +292,25 @@ class MyDialog final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback methods // Callback methods
void cb_noFunctionMsg (finalcut::FWidget*, const FDataPtr); void cb_noFunctionMsg (const finalcut::FButton&);
void cb_about (const finalcut::FWidget*, const FDataPtr); void cb_about();
void cb_terminfo (const finalcut::FWidget*, const FDataPtr); void cb_terminfo();
void cb_drives (const finalcut::FWidget*, const FDataPtr); void cb_drives();
void cb_cutClipboard (const finalcut::FWidget*, const FDataPtr); void cb_cutClipboard();
void cb_copyClipboard (const finalcut::FWidget*, const FDataPtr); void cb_copyClipboard();
void cb_pasteClipboard (const finalcut::FWidget*, const FDataPtr); void cb_pasteClipboard();
void cb_clearInput (const finalcut::FWidget*, const FDataPtr); void cb_clearInput();
void cb_switchTheme (const finalcut::FWidget*, const FDataPtr); void cb_switchTheme (const finalcut::FCheckMenuItem*) const;
void cb_input2buttonText (finalcut::FWidget*, FDataPtr); void cb_input2buttonText ( finalcut::FButton&
void cb_setTitlebar (finalcut::FWidget*, const FDataPtr); , const finalcut::FLineEdit& ) const;
void cb_showProgressBar (const finalcut::FWidget*, const FDataPtr); void cb_setTitlebar (const finalcut::FLineEdit&);
void cb_updateNumber (finalcut::FWidget*, FDataPtr); void cb_showProgressBar();
void cb_activateButton (finalcut::FWidget*, FDataPtr); void cb_updateNumber ( const finalcut::FListBox&
void cb_view (const finalcut::FWidget*, FDataPtr); , finalcut::FLabel& ) const;
void cb_setInput (finalcut::FWidget*, FDataPtr); void cb_activateButton ( const finalcut::FRadioButton&
, finalcut::FButton& ) const;
void cb_view (const finalcut::FMenuItem*);
void cb_setInput (const finalcut::FListBox&, finalcut::FLineEdit&) const;
// Data members // Data members
bool initialized{false}; bool initialized{false};
@ -448,35 +450,38 @@ void MyDialog::initFileMenuCallbacks()
Open.addCallback Open.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view) this, &MyDialog::cb_view,
nullptr
); );
Quit.addCallback Quit.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
// System files submenu // System files submenu
File1.addCallback File1.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), this, &MyDialog::cb_view,
static_cast<FDataPtr>(&File1) &File1
); );
File2.addCallback File2.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), this, &MyDialog::cb_view,
static_cast<FDataPtr>(&File2) &File2
); );
File3.addCallback File3.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_view), this, &MyDialog::cb_view,
static_cast<FDataPtr>(&File3) &File3
); );
} }
@ -487,25 +492,25 @@ void MyDialog::initEditMenuCallbacks()
Cut.addCallback Cut.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_cutClipboard) this, &MyDialog::cb_cutClipboard
); );
Copy.addCallback Copy.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_copyClipboard) this, &MyDialog::cb_copyClipboard
); );
Paste.addCallback Paste.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_pasteClipboard) this, &MyDialog::cb_pasteClipboard
); );
Clear.addCallback Clear.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_clearInput) this, &MyDialog::cb_clearInput
); );
} }
@ -516,19 +521,20 @@ void MyDialog::initViewMenuCallbacks()
Env.addCallback Env.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_terminfo) this, &MyDialog::cb_terminfo
); );
Drive.addCallback Drive.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_drives) this, &MyDialog::cb_drives
); );
Theme.addCallback Theme.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_switchTheme) this, &MyDialog::cb_switchTheme,
&Theme
); );
} }
@ -538,7 +544,7 @@ void MyDialog::initHelpMenuCallback()
Help.addCallback Help.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_about) this, &MyDialog::cb_about
); );
} }
@ -550,19 +556,22 @@ void MyDialog::initStatusBarCallbacks()
key_F1.addCallback key_F1.addCallback
( (
"activate", "activate",
F_METHOD_CALLBACK (this, &MyDialog::cb_about) this, &MyDialog::cb_about
); );
key_F2.addCallback key_F2.addCallback
( (
"activate", "activate",
F_METHOD_CALLBACK (this, &MyDialog::cb_view) this, &MyDialog::cb_view,
nullptr
); );
key_F3.addCallback key_F3.addCallback
( (
"activate", "activate",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }
@ -627,19 +636,22 @@ void MyDialog::initFlatButtons()
MyButton1.addCallback MyButton1.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg) this, &MyDialog::cb_noFunctionMsg,
std::ref(MyButton1)
); );
MyButton2.addCallback MyButton2.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg) this, &MyDialog::cb_noFunctionMsg,
std::ref(MyButton2)
); );
MyButton3.addCallback MyButton3.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_noFunctionMsg) this, &MyDialog::cb_noFunctionMsg,
std::ref(MyButton3)
); );
} }
@ -693,20 +705,22 @@ void MyDialog::initButtons()
MyButton4.addCallback MyButton4.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), this, &MyDialog::cb_input2buttonText,
static_cast<FDataPtr>(&myLineEdit) std::ref(MyButton4), std::cref(myLineEdit)
); );
MyButton5.addCallback MyButton5.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_showProgressBar) this, &MyDialog::cb_showProgressBar
); );
MyButton6.addCallback MyButton6.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }
@ -739,28 +753,29 @@ void MyDialog::initWidgetsCallbacks()
myLineEdit.addCallback myLineEdit.addCallback
( (
"activate", // e.g. on <Enter> "activate", // e.g. on <Enter>
F_METHOD_CALLBACK (this, &MyDialog::cb_setTitlebar) this, &MyDialog::cb_setTitlebar,
std::ref(myLineEdit)
); );
radio1.addCallback radio1.addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &MyDialog::cb_activateButton), this, &MyDialog::cb_activateButton,
static_cast<FDataPtr>(&MyButton5) std::ref(radio1), std::ref(MyButton5)
); );
myList.addCallback myList.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MyDialog::cb_setInput), this, &MyDialog::cb_setInput,
static_cast<FDataPtr>(&myLineEdit) std::ref(myList), std::ref(myLineEdit)
); );
myList.addCallback myList.addCallback
( (
"row-selected", "row-selected",
F_METHOD_CALLBACK (this, &MyDialog::cb_updateNumber), this, &MyDialog::cb_updateNumber,
static_cast<FDataPtr>(&tagged_count) std::ref(myList), std::ref(tagged_count)
); );
} }
@ -789,9 +804,8 @@ void MyDialog::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, const FDataPtr) void MyDialog::cb_noFunctionMsg (const finalcut::FButton& button)
{ {
auto& button = *(static_cast<finalcut::FButton*>(widget));
auto text = button.getText(); auto text = button.getText();
text = text.replace('&', ""); text = text.replace('&', "");
finalcut::FMessageBox::error ( this finalcut::FMessageBox::error ( this
@ -800,13 +814,13 @@ void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_about (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_about()
{ {
constexpr char libver[] = F_VERSION; constexpr char libver[] = F_VERSION;
const finalcut::FString line(2, fc::BoxDrawingsHorizontal); const finalcut::FString line(2, fc::BoxDrawingsHorizontal);
finalcut::FMessageBox info ( "About" finalcut::FMessageBox info ( "About"
, line + L" The Final Cut " + line + L"\n\n" , line + L" FINAL CUT " + line + L"\n\n"
L"Version " + libver + L"\n\n" L"Version " + libver + L"\n\n"
L"(c) 2020 by Markus Gans" L"(c) 2020 by Markus Gans"
, finalcut::FMessageBox::Ok, 0, 0, this ); , finalcut::FMessageBox::Ok, 0, 0, this );
@ -815,7 +829,7 @@ void MyDialog::cb_about (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_terminfo (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_terminfo()
{ {
const auto x = getDesktopWidth(); const auto x = getDesktopWidth();
const auto y = getDesktopHeight(); const auto y = getDesktopHeight();
@ -836,7 +850,7 @@ void MyDialog::cb_terminfo (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_drives (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_drives()
{ {
finalcut::FMessageBox info2 \ finalcut::FMessageBox info2 \
( (
@ -887,7 +901,7 @@ void MyDialog::cb_drives (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_cutClipboard (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_cutClipboard()
{ {
clipboard = myLineEdit.getText(); clipboard = myLineEdit.getText();
myLineEdit.clear(); myLineEdit.clear();
@ -895,20 +909,20 @@ void MyDialog::cb_cutClipboard (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_copyClipboard (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_copyClipboard()
{ {
clipboard = myLineEdit.getText(); clipboard = myLineEdit.getText();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_pasteClipboard (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_pasteClipboard()
{ {
myLineEdit = clipboard; myLineEdit = clipboard;
myLineEdit.redraw(); myLineEdit.redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_clearInput (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_clearInput()
{ {
clipboard.clear(); clipboard.clear();
myLineEdit.clear(); myLineEdit.clear();
@ -916,11 +930,9 @@ void MyDialog::cb_clearInput (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_switchTheme (const finalcut::FWidget* widget, const FDataPtr) void MyDialog::cb_switchTheme (const finalcut::FCheckMenuItem* check_menu) const
{ {
const auto& check_menu = *(static_cast<const finalcut::FCheckMenuItem*>(widget)); if ( check_menu->isChecked() )
if ( check_menu.isChecked() )
finalcut::FApplication::setDarkTheme(); finalcut::FApplication::setDarkTheme();
else else
finalcut::FApplication::setDefaultTheme(); finalcut::FApplication::setDefaultTheme();
@ -931,18 +943,16 @@ void MyDialog::cb_switchTheme (const finalcut::FWidget* widget, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_input2buttonText (finalcut::FWidget* widget, FDataPtr data) void MyDialog::cb_input2buttonText ( finalcut::FButton& button
, const finalcut::FLineEdit& lineedit ) const
{ {
auto& button = *(static_cast<finalcut::FButton*>(widget));
const auto& lineedit = *(static_cast<finalcut::FLineEdit*>(data));
button.setText(lineedit.getText()); button.setText(lineedit.getText());
button.redraw(); button.redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, const FDataPtr) void MyDialog::cb_setTitlebar (const finalcut::FLineEdit& lineedit)
{ {
auto& lineedit = *(static_cast<finalcut::FLineEdit*>(widget));
finalcut::FString title{}; finalcut::FString title{};
lineedit >> title; lineedit >> title;
finalcut::FTerm::setTermTitle (title); finalcut::FTerm::setTermTitle (title);
@ -951,17 +961,16 @@ void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_showProgressBar (const finalcut::FWidget*, const FDataPtr) void MyDialog::cb_showProgressBar()
{ {
auto p_dgl = new ProgressDialog(this); auto p_dgl = new ProgressDialog(this);
p_dgl->show(); p_dgl->show();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_updateNumber (finalcut::FWidget* widget, FDataPtr data) void MyDialog::cb_updateNumber ( const finalcut::FListBox& list
, finalcut::FLabel& num) const
{ {
const auto& list = *(static_cast<finalcut::FListBox*>(widget));
auto& num = *(static_cast<finalcut::FLabel*>(data));
const auto count = list.getCount(); const auto count = list.getCount();
int select_num = 0; int select_num = 0;
@ -975,11 +984,9 @@ void MyDialog::cb_updateNumber (finalcut::FWidget* widget, FDataPtr data)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_activateButton (finalcut::FWidget* widget, FDataPtr data) void MyDialog::cb_activateButton ( const finalcut::FRadioButton& rb
, finalcut::FButton& button) const
{ {
const auto& rb = *(static_cast<finalcut::FRadioButton*>(widget));
auto& button = *(static_cast<finalcut::FButton*>(data));
if ( rb.isChecked() ) if ( rb.isChecked() )
button.setEnable(); button.setEnable();
else else
@ -989,10 +996,9 @@ void MyDialog::cb_activateButton (finalcut::FWidget* widget, FDataPtr data)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_view (const finalcut::FWidget*, FDataPtr data) void MyDialog::cb_view (const finalcut::FMenuItem* item)
{ {
finalcut::FString file{}; finalcut::FString file{};
const auto& item = static_cast<finalcut::FMenuItem*>(data);
if ( item && ! item->getText().isEmpty() ) if ( item && ! item->getText().isEmpty() )
file = item->getText(); file = item->getText();
@ -1026,11 +1032,10 @@ void MyDialog::cb_view (const finalcut::FWidget*, FDataPtr data)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MyDialog::cb_setInput (finalcut::FWidget* widget, FDataPtr data) void MyDialog::cb_setInput ( const finalcut::FListBox& listbox
, finalcut::FLineEdit& lineedit) const
{ {
auto& ListBox = *(static_cast<finalcut::FListBox*>(widget)); lineedit = listbox.getItem(listbox.currentItem()).getText();
auto& lineedit = *(static_cast<finalcut::FLineEdit*>(data));
lineedit = ListBox.getItem(ListBox.currentItem()).getText();
lineedit.redraw(); lineedit.redraw();
} }
@ -1042,24 +1047,12 @@ void MyDialog::cb_setInput (finalcut::FWidget* widget, FDataPtr data)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
const finalcut::FString ver{F_VERSION}; // Library version const finalcut::FString ver{F_VERSION}; // Library version
const finalcut::FString title { "The FINAL CUT " const finalcut::FString title { "FINAL CUT " + ver
+ ver
+ " (C) 2020 by Markus Gans" }; + " (C) 2020 by Markus Gans" };
// Create the application object app // Create the application object app
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
app.setNonBlockingRead(); app.setNonBlockingRead();
finalcut::FTerm::redefineDefaultColors(true);
finalcut::FTerm::setTermTitle (title);
// Force vt100 encoding
//finalcut::FTerm::setEncoding(finalcut::fc::VT100);
// Sets the terminal size to 94×30
//finalcut::FTerm::setTermSize(FSize{94, 30});
// Enable the final cut graphical font
//finalcut::FTerm::setNewFont();
// Create main dialog object d // Create main dialog object d
MyDialog d{&app}; MyDialog d{&app};
@ -1075,6 +1068,15 @@ int main (int argc, char* argv[])
// Show the dialog d // Show the dialog d
d.show(); d.show();
finalcut::FTerm::redefineDefaultColors(true);
finalcut::FTerm::setTermTitle (title);
// Sets the terminal size to 94×30
//finalcut::FTerm::setTermSize(FSize{94, 30});
// Enable the final cut graphical font
//finalcut::FTerm::setNewFont();
// Start the application // Start the application
// and return the result to the operating system // and return the result to the operating system
return app.exec(); return app.exec();

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* watch.cpp - A watch with FSwitch widgets * * watch.cpp - A watch with FSwitch widgets *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -54,8 +54,8 @@ class Watch final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback methods // Callback methods
void cb_clock (const finalcut::FWidget*, const FDataPtr); void cb_clock();
void cb_seconds (const finalcut::FWidget*, const FDataPtr); void cb_seconds();
protected: protected:
// Method // Method
@ -99,21 +99,23 @@ Watch::Watch (FWidget* parent)
clock_sw.addCallback clock_sw.addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &Watch::cb_clock) this, &Watch::cb_clock
); );
// Connect switch signal "toggled" with a callback member function // Connect switch signal "toggled" with a callback member function
seconds_sw.addCallback seconds_sw.addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &Watch::cb_seconds) this, &Watch::cb_seconds
); );
// Connect button signal "clicked" with a callback member function // Connect button signal "clicked" with a callback member function
quit_btn.addCallback quit_btn.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) finalcut::getFApplication(),
&finalcut::FApplication::cb_exitApp,
this
); );
} }
@ -152,7 +154,7 @@ void Watch::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Watch::cb_clock (const finalcut::FWidget*, const FDataPtr) void Watch::cb_clock()
{ {
if ( clock_sw.isChecked() ) if ( clock_sw.isChecked() )
{ {
@ -161,14 +163,14 @@ void Watch::cb_clock (const finalcut::FWidget*, const FDataPtr)
} }
else else
{ {
delAllTimer(); // Delete all timers and stop updating the time delAllTimers(); // Delete all timers and stop updating the time
time_str = "--:--:--"; time_str = "--:--:--";
time_str.redraw(); time_str.redraw();
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Watch::cb_seconds (const finalcut::FWidget*, const FDataPtr) void Watch::cb_seconds()
{ {
if ( seconds_sw.isChecked() ) if ( seconds_sw.isChecked() )
sec = true; sec = true;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* windows.cpp - Shows window handling * * windows.cpp - Shows window handling *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,7 +20,9 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <utility>
#include <vector> #include <vector>
#include <final/final.h> #include <final/final.h>
namespace fc = finalcut::fc; namespace fc = finalcut::fc;
@ -84,12 +86,12 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
right_arrow.ignorePadding(); right_arrow.ignorePadding();
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1}); right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
top_left_label = "menu"; top_left_label.setText("menu");
top_left_label.setForegroundColor (wc->label_inactive_fg); top_left_label.setForegroundColor (wc->label_inactive_fg);
top_left_label.setEmphasis(); top_left_label.setEmphasis();
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1}); top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
top_right_label = "zoom"; top_right_label.setText("zoom");
top_right_label.setAlignment (fc::alignRight); top_right_label.setAlignment (fc::alignRight);
top_right_label.setForegroundColor (wc->label_inactive_fg); top_right_label.setForegroundColor (wc->label_inactive_fg);
top_right_label.setEmphasis(); top_right_label.setEmphasis();
@ -152,7 +154,7 @@ void SmallWindow::onTimer (finalcut::FTimerEvent*)
bottom_label.unsetEmphasis(); bottom_label.unsetEmphasis();
bottom_label.redraw(); bottom_label.redraw();
updateTerminal(); updateTerminal();
delOwnTimer(); delOwnTimers();
} }
@ -176,10 +178,6 @@ class Window final : public finalcut::FDialog
Window& operator = (const Window&) = delete; Window& operator = (const Window&) = delete;
private: private:
// Typedefs
typedef void (Window::*WindowCallback)(const finalcut::FWidget*, const FDataPtr);
typedef void (finalcut::FApplication::*FAppCallback)(const finalcut::FWidget*, const FDataPtr);
struct win_data struct win_data
{ {
// Constructor // Constructor
@ -199,10 +197,11 @@ class Window final : public finalcut::FDialog
// Method // Method
void configureFileMenuItems(); void configureFileMenuItems();
void configureDialogButtons(); void configureDialogButtons();
void activateWindow (finalcut::FDialog*); void activateWindow (finalcut::FDialog*) const;
void adjustSize() override; void adjustSize() override;
template<typename CallbackT> template<typename InstanceT, typename CallbackT, typename... Args>
void addClickedCallback (finalcut::FWidget*, CallbackT); void addClickedCallback ( finalcut::FWidget*
, InstanceT&&, CallbackT&&, Args&&... );
template <typename IteratorT> template <typename IteratorT>
finalcut::FDialog* getNext (IteratorT); finalcut::FDialog* getNext (IteratorT);
template <typename IteratorT> template <typename IteratorT>
@ -212,11 +211,11 @@ class Window final : public finalcut::FDialog
void onClose (finalcut::FCloseEvent*) override; void onClose (finalcut::FCloseEvent*) override;
// Callback methods // Callback methods
void cb_createWindows (const finalcut::FWidget*, const FDataPtr); void cb_createWindows();
void cb_closeWindows (const finalcut::FWidget*, const FDataPtr); void cb_closeWindows();
void cb_next (const finalcut::FWidget*, const FDataPtr); void cb_next();
void cb_previous (const finalcut::FWidget*, const FDataPtr); void cb_previous();
void cb_destroyWindow (const finalcut::FWidget*, FDataPtr); void cb_destroyWindow (win_data*) const;
// Data members // Data members
std::vector<win_data*> windows{}; std::vector<win_data*> windows{};
@ -277,7 +276,7 @@ Window::~Window()
// Remove all callbacks before Window::cb_destroyWindow() will be called // Remove all callbacks before Window::cb_destroyWindow() will be called
if ( win_dat->is_open && win_dat->dgl ) if ( win_dat->is_open && win_dat->dgl )
win_dat->dgl->delCallbacks(); win_dat->dgl->delCallback();
delete win_dat; delete win_dat;
iter = windows.erase(iter); iter = windows.erase(iter);
@ -300,11 +299,14 @@ void Window::configureFileMenuItems()
Quit.setStatusbarMessage ("Exit the program"); Quit.setStatusbarMessage ("Exit the program");
// Add menu item callback // Add menu item callback
addClickedCallback (&New, &Window::cb_createWindows); addClickedCallback (&New, this, &Window::cb_createWindows);
addClickedCallback (&Close, &Window::cb_closeWindows); addClickedCallback (&Close, this, &Window::cb_closeWindows);
addClickedCallback (&Next, &Window::cb_next); addClickedCallback (&Next, this, &Window::cb_next);
addClickedCallback (&Previous, &Window::cb_previous); addClickedCallback (&Previous, this, &Window::cb_previous);
addClickedCallback (&Quit, &finalcut::FApplication::cb_exitApp); addClickedCallback ( &Quit
, finalcut::getFApplication()
, &finalcut::FApplication::cb_exitApp
, this );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -319,13 +321,16 @@ void Window::configureDialogButtons()
QuitButton.setText (L"&Quit"); QuitButton.setText (L"&Quit");
// Add button callback // Add button callback
addClickedCallback (&CreateButton, &Window::cb_createWindows); addClickedCallback (&CreateButton, this, &Window::cb_createWindows);
addClickedCallback (&CloseButton, &Window::cb_closeWindows); addClickedCallback (&CloseButton, this, &Window::cb_closeWindows);
addClickedCallback (&QuitButton, &finalcut::FApplication::cb_exitApp); addClickedCallback ( &QuitButton
, finalcut::getFApplication()
, &finalcut::FApplication::cb_exitApp
, this );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::activateWindow (finalcut::FDialog* win) void Window::activateWindow (finalcut::FDialog* win) const
{ {
if ( ! win || win->isWindowHidden() || win->isWindowActive() ) if ( ! win || win->isWindowHidden() || win->isWindowActive() )
return; return;
@ -373,17 +378,18 @@ void Window::adjustSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename CallbackT> template<typename InstanceT, typename CallbackT, typename... Args>
void Window::addClickedCallback ( finalcut::FWidget* widget void Window::addClickedCallback ( finalcut::FWidget* widget
, CallbackT call ) , InstanceT&& instance
, CallbackT&& callback
, Args&&... args )
{ {
FMemberCallback callback
= reinterpret_cast<FMemberCallback>(call);
widget->addCallback widget->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, callback) std::bind ( std::forward<CallbackT>(callback)
, std::forward<InstanceT>(instance)
, std::forward<Args>(args)... )
); );
} }
@ -439,7 +445,7 @@ void Window::onClose (finalcut::FCloseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_createWindows (const finalcut::FWidget*, const FDataPtr) void Window::cb_createWindows()
{ {
const auto& first = windows.begin(); const auto& first = windows.begin();
auto iter = first; auto iter = first;
@ -468,8 +474,8 @@ void Window::cb_createWindows (const finalcut::FWidget*, const FDataPtr)
win->addCallback win->addCallback
( (
"destroy", "destroy",
F_METHOD_CALLBACK (this, &Window::cb_destroyWindow), this, &Window::cb_destroyWindow,
static_cast<FDataPtr>(win_dat) win_dat
); );
} }
@ -480,7 +486,7 @@ void Window::cb_createWindows (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_closeWindows (const finalcut::FWidget*, const FDataPtr) void Window::cb_closeWindows()
{ {
if ( ! getDialogList() || getDialogList()->empty() ) if ( ! getDialogList() || getDialogList()->empty() )
return; return;
@ -500,7 +506,7 @@ void Window::cb_closeWindows (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_next (const finalcut::FWidget*, const FDataPtr) void Window::cb_next()
{ {
if ( ! getDialogList() || getDialogList()->empty() ) if ( ! getDialogList() || getDialogList()->empty() )
return; return;
@ -520,7 +526,7 @@ void Window::cb_next (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_previous (const finalcut::FWidget*, const FDataPtr) void Window::cb_previous()
{ {
if ( ! getDialogList() || getDialogList()->empty() ) if ( ! getDialogList() || getDialogList()->empty() )
return; return;
@ -542,10 +548,8 @@ void Window::cb_previous (const finalcut::FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::cb_destroyWindow (const finalcut::FWidget*, FDataPtr data) void Window::cb_destroyWindow (win_data* win_dat) const
{ {
auto win_dat = static_cast<win_data*>(data);
if ( win_dat ) if ( win_dat )
{ {
win_dat->is_open = false; win_dat->is_open = false;

View File

@ -29,3 +29,7 @@ font_DATA = \
8x16graph.pcf.gz \ 8x16graph.pcf.gz \
fonts.alias \ fonts.alias \
fonts.dir fonts.dir
uninstall-hook:
if test -d ${fontdir}; then rmdir ${fontdir}; fi

View File

@ -1,92 +0,0 @@
dnl
dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl
AC_DEFUN([AM_PATH_CPPUNIT],
[
AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
cppunit_config_prefix="$withval", cppunit_config_prefix="")
AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
if test x$cppunit_config_exec_prefix != x ; then
cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
if test x${CPPUNIT_CONFIG+set} != xset ; then
CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
fi
fi
if test x$cppunit_config_prefix != x ; then
cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
if test x${CPPUNIT_CONFIG+set} != xset ; then
CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
fi
fi
AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
cppunit_version_min=$1
AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
no_cppunit=""
if test "$CPPUNIT_CONFIG" = "no" ; then
AC_MSG_RESULT(no)
no_cppunit=yes
else
CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
cppunit_version=`$CPPUNIT_CONFIG --version`
cppunit_major_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
cppunit_minor_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
cppunit_micro_version=`echo $cppunit_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
cppunit_major_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
if test "x${cppunit_major_min}" = "x" ; then
cppunit_major_min=0
fi
cppunit_minor_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
if test "x${cppunit_minor_min}" = "x" ; then
cppunit_minor_min=0
fi
cppunit_micro_min=`echo $cppunit_version_min | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x${cppunit_micro_min}" = "x" ; then
cppunit_micro_min=0
fi
cppunit_version_proper=`expr \
$cppunit_major_version \> $cppunit_major_min \| \
$cppunit_major_version \= $cppunit_major_min \& \
$cppunit_minor_version \> $cppunit_minor_min \| \
$cppunit_major_version \= $cppunit_major_min \& \
$cppunit_minor_version \= $cppunit_minor_min \& \
$cppunit_micro_version \>= $cppunit_micro_min `
if test "$cppunit_version_proper" = "1" ; then
AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
else
AC_MSG_RESULT(no)
no_cppunit=yes
fi
fi
if test "x$no_cppunit" = x ; then
ifelse([$2], , :, [$2])
else
CPPUNIT_CFLAGS=""
CPPUNIT_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(CPPUNIT_CFLAGS)
AC_SUBST(CPPUNIT_LIBS)
])

View File

@ -1,5 +1,5 @@
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Makefile.am - The Final Cut library # Makefile.am - FINAL CUT library
#---------------------------------------------------------------------- #----------------------------------------------------------------------
AM_CPPFLAGS = -Iinclude -Wall -Werror -DCOMPILE_FINAL_CUT -std=c++11 AM_CPPFLAGS = -Iinclude -Wall -Werror -DCOMPILE_FINAL_CUT -std=c++11
@ -19,6 +19,7 @@ libfinal_la_SOURCES = \
flineedit.cpp \ flineedit.cpp \
fbutton.cpp \ fbutton.cpp \
fbuttongroup.cpp \ fbuttongroup.cpp \
fcallback.cpp \
ftogglebutton.cpp \ ftogglebutton.cpp \
fradiobutton.cpp \ fradiobutton.cpp \
fcheckbox.cpp \ fcheckbox.cpp \
@ -44,6 +45,7 @@ libfinal_la_SOURCES = \
fwindow.cpp \ fwindow.cpp \
fmessagebox.cpp \ fmessagebox.cpp \
ftooltip.cpp \ ftooltip.cpp \
fbusyindicator.cpp \
ffiledialog.cpp \ ffiledialog.cpp \
fkey_map.cpp \ fkey_map.cpp \
fcharmap.cpp \ fcharmap.cpp \
@ -84,8 +86,10 @@ finalcutinclude_HEADERS = \
include/final/fapplication.h \ include/final/fapplication.h \
include/final/fbutton.h \ include/final/fbutton.h \
include/final/fbuttongroup.h \ include/final/fbuttongroup.h \
include/final/fcallback.h \
include/final/fcheckbox.h \ include/final/fcheckbox.h \
include/final/fcolorpair.h \ include/final/fcolorpair.h \
include/final/fdata.h \
include/final/fstyle.h \ include/final/fstyle.h \
include/final/fconfig.h \ include/final/fconfig.h \
include/final/fswitch.h \ include/final/fswitch.h \
@ -115,6 +119,7 @@ finalcutinclude_HEADERS = \
include/final/fmenulist.h \ include/final/fmenulist.h \
include/final/fmessagebox.h \ include/final/fmessagebox.h \
include/final/ftooltip.h \ include/final/ftooltip.h \
include/final/fbusyindicator.h \
include/final/fobject.h \ include/final/fobject.h \
include/final/fpoint.h \ include/final/fpoint.h \
include/final/fsize.h \ include/final/fsize.h \
@ -157,5 +162,6 @@ finalcutinclude_HEADERS = \
clean-local: clean-local:
-find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete
#uninstall: uninstall-hook:
# rm -R -f $(includedir)/final if test -d ${finalcutincludedir}; then rmdir ${finalcutincludedir}; fi

View File

@ -1,5 +1,5 @@
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Makefile for Final Cut # Makefile for FINAL CUT
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# This is where make install will install the library # This is where make install will install the library
@ -12,6 +12,7 @@ INCLUDE_HEADERS = \
fapplication.h \ fapplication.h \
fbuttongroup.h \ fbuttongroup.h \
fbutton.h \ fbutton.h \
fcallback.h \
fcolorpair.h \ fcolorpair.h \
fstyle.h \ fstyle.h \
ftogglebutton.h \ ftogglebutton.h \
@ -34,6 +35,7 @@ INCLUDE_HEADERS = \
fcheckmenuitem.h \ fcheckmenuitem.h \
fmessagebox.h \ fmessagebox.h \
ftooltip.h \ ftooltip.h \
fbusyindicator.h \
sgr_optimizer.h \ sgr_optimizer.h \
foptiattr.h \ foptiattr.h \
foptimove.h \ foptimove.h \
@ -90,6 +92,7 @@ OBJS = \
fpoint.o \ fpoint.o \
fsize.o \ fsize.o \
frect.o \ frect.o \
fcallback.o \
fscrollbar.o \ fscrollbar.o \
fprogressbar.o \ fprogressbar.o \
flineedit.o \ flineedit.o \
@ -118,6 +121,7 @@ OBJS = \
fcombobox.o \ fcombobox.o \
fmessagebox.o \ fmessagebox.o \
ftooltip.o \ ftooltip.o \
fbusyindicator.o \
ffiledialog.o \ ffiledialog.o \
fkey_map.o \ fkey_map.o \
fcharmap.o \ fcharmap.o \

View File

@ -1,5 +1,5 @@
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Makefile for Final Cut # Makefile for FINAL CUT
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# This is where make install will install the library # This is where make install will install the library
@ -12,6 +12,7 @@ INCLUDE_HEADERS = \
fapplication.h \ fapplication.h \
fbuttongroup.h \ fbuttongroup.h \
fbutton.h \ fbutton.h \
fcallback.h \
fcolorpair.h \ fcolorpair.h \
fstyle.h \ fstyle.h \
ftogglebutton.h \ ftogglebutton.h \
@ -34,6 +35,7 @@ INCLUDE_HEADERS = \
fcheckmenuitem.h \ fcheckmenuitem.h \
fmessagebox.h \ fmessagebox.h \
ftooltip.h \ ftooltip.h \
fbusyindicator.h \
sgr_optimizer.h \ sgr_optimizer.h \
foptiattr.h \ foptiattr.h \
foptimove.h \ foptimove.h \
@ -90,6 +92,7 @@ OBJS = \
fpoint.o \ fpoint.o \
fsize.o \ fsize.o \
frect.o \ frect.o \
fcallback.o \
fscrollbar.o \ fscrollbar.o \
fprogressbar.o \ fprogressbar.o \
flineedit.o \ flineedit.o \
@ -118,6 +121,7 @@ OBJS = \
fcombobox.o \ fcombobox.o \
fmessagebox.o \ fmessagebox.o \
ftooltip.o \ ftooltip.o \
fbusyindicator.o \
ffiledialog.o \ ffiledialog.o \
fkey_map.o \ fkey_map.o \
fcharmap.o \ fcharmap.o \

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fapplication.cpp - Manages the application events * * fapplication.cpp - Manages the application events *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2013-2020 Markus Gans * * Copyright 2013-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,8 +20,11 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <chrono>
#include <fstream>
#include <memory> #include <memory>
#include <string> #include <string>
#include <thread>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fevent.h" #include "final/fevent.h"
@ -58,9 +61,10 @@ FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard foc
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
FMouseControl* FApplication::mouse {nullptr}; // mouse control FMouseControl* FApplication::mouse {nullptr}; // mouse control
int FApplication::loop_level {0}; // event loop level int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {0}; int FApplication::quit_code {EXIT_SUCCESS};
bool FApplication::quit_now {false}; bool FApplication::quit_now {false};
uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms /200 Hz
struct timeval FApplication::time_last_event{};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FApplication // class FApplication
@ -68,13 +72,14 @@ bool FApplication::quit_now {false};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FApplication::FApplication ( const int& _argc FApplication::FApplication (const int& _argc, char* _argv[])
, char* _argv[] : FWidget{processParameters(_argc, _argv)}
, bool disable_alt_screen )
: FWidget{processParameters(_argc, _argv), disable_alt_screen}
, app_argc{_argc} , app_argc{_argc}
, app_argv{_argv} , app_argv{_argv}
{ {
if ( quit_now )
return;
if ( app_object ) if ( app_object )
{ {
auto ftermdata = FTerm::getFTermData(); auto ftermdata = FTerm::getFTermData();
@ -84,6 +89,7 @@ FApplication::FApplication ( const int& _argc
return; return;
} }
// First define the application object
app_object = this; app_object = this;
if ( ! (_argc && _argv) ) if ( ! (_argc && _argv) )
@ -93,7 +99,7 @@ FApplication::FApplication ( const int& _argc
app_argv = reinterpret_cast<char**>(&empty_str); app_argv = reinterpret_cast<char**>(&empty_str);
} }
init (key_timeout, dblclick_interval); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -145,10 +151,10 @@ int FApplication::exec() // run
if ( quit_now ) if ( quit_now )
{ {
quit_now = false; quit_now = false;
return EXIT_FAILURE; return quit_code;
} }
quit_code = 0; quit_code = EXIT_SUCCESS;
enterLoop(); enterLoop();
return quit_code; return quit_code;
} }
@ -171,7 +177,7 @@ int FApplication::enterLoop() // event loop
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::exitLoop() void FApplication::exitLoop() const
{ {
app_exit_loop = true; app_exit_loop = true;
} }
@ -184,7 +190,7 @@ void FApplication::exit (int retcode)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::quit() void FApplication::quit() const
{ {
FApplication::exit(0); FApplication::exit(0);
} }
@ -228,7 +234,7 @@ void FApplication::sendQueuedEvents()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::eventInQueue() bool FApplication::eventInQueue() const
{ {
if ( app_object ) if ( app_object )
return ( ! event_queue.empty() ); return ( ! event_queue.empty() );
@ -263,23 +269,10 @@ bool FApplication::removeQueuedEvent (const FObject* receiver)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processExternalUserEvent() void FApplication::initTerminal()
{ {
// This method can be overloaded and replaced by own code if ( ! isQuit() )
} FWidget::initTerminal();
//----------------------------------------------------------------------
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 ) )
{
showParameterUsage();
}
getStartOptions().setDefault();
cmd_options (argc, argv);
return nullptr;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -288,14 +281,14 @@ void FApplication::setDefaultTheme()
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
{ {
if ( getStartOptions().color_change ) if ( getStartOptions().color_change )
FTerm::setColorPaletteTheme<default8ColorPalette>(&FTerm::setPalette); FTerm::setColorPaletteTheme<default8ColorPalette>();
setColorTheme<default8ColorTheme>(); setColorTheme<default8ColorTheme>();
} }
else else
{ {
if ( getStartOptions().color_change ) if ( getStartOptions().color_change )
FTerm::setColorPaletteTheme<default16ColorPalette>(&FTerm::setPalette); FTerm::setColorPaletteTheme<default16ColorPalette>();
setColorTheme<default16ColorTheme>(); setColorTheme<default16ColorTheme>();
} }
@ -305,7 +298,7 @@ void FApplication::setDefaultTheme()
void FApplication::setDarkTheme() void FApplication::setDarkTheme()
{ {
if ( getStartOptions().color_change ) if ( getStartOptions().color_change )
FTerm::setColorPaletteTheme<default16DarkColorPalette>(&FTerm::setPalette); FTerm::setColorPaletteTheme<default16DarkColorPalette>();
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
setColorTheme<default8ColorDarkTheme>(); setColorTheme<default8ColorDarkTheme>();
@ -313,6 +306,220 @@ void FApplication::setDarkTheme()
setColorTheme<default16ColorDarkTheme>(); setColorTheme<default16ColorDarkTheme>();
} }
//----------------------------------------------------------------------
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
{
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 )
ev->accept();
else
{
ev->ignore();
// Status bar restore after closing the FMessageBox
if ( getStatusBar() )
getStatusBar()->drawMessage();
}
}
// protected methods of FApplication
//----------------------------------------------------------------------
void FApplication::processExternalUserEvent()
{
// This method can be overloaded and replaced by own code
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
// private methods of FApplication
//----------------------------------------------------------------------
void FApplication::init()
{
// Initialize the last event time
time_last_event.tv_sec = 0;
time_last_event.tv_usec = 0;
// Initialize keyboard
keyboard = FTerm::getFKeyboard();
// Set the keyboard keypress timeout
if ( keyboard )
{
auto cmd1 = std::bind(&FApplication::keyPressed, this);
auto cmd2 = std::bind(&FApplication::keyReleased, this);
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
FKeyboardCommand key_cmd1 (cmd1);
FKeyboardCommand key_cmd2 (cmd2);
FKeyboardCommand key_cmd3 (cmd3);
keyboard->setPressCommand (key_cmd1);
keyboard->setReleaseCommand (key_cmd2);
keyboard->setEscPressedCommand (key_cmd3);
keyboard->setKeypressTimeout (key_timeout);
}
// Initialize mouse control
mouse = FTerm::getFMouseControl();
// Set stdin number for a gpm-mouse
if ( mouse )
mouse->setStdinNo (FTermios::getStdIn());
// Set the default double click interval
if ( mouse )
mouse->setDblclickInterval (dblclick_interval);
// Initialize logging
if ( ! getStartOptions().logfile_stream.is_open() )
getLog()->setLineEnding(FLog::CRLF);
}
//----------------------------------------------------------------------
void FApplication::setTerminalEncoding (const FString& enc_str)
{
const FString& enc = enc_str.toLower();
if ( enc.includes("utf8") )
getStartOptions().encoding = fc::UTF8;
else if ( enc.includes("vt100") )
getStartOptions().encoding = fc::VT100;
else if ( enc.includes("pc") )
getStartOptions().encoding = fc::PC;
else if ( enc.includes("ascii") )
getStartOptions().encoding = fc::ASCII;
else if ( enc.includes("help") )
showParameterUsage();
else
{
auto ftermdata = FTerm::getFTermData();
ftermdata->setExitMessage ( "Unknown encoding \"" + enc_str
+ "\"\n(Valid encodings are utf8, "
+ "vt100, pc and ascii)" );
exit(EXIT_FAILURE);
}
}
//----------------------------------------------------------------------
void FApplication::setLogFile (const FString& filename)
{
auto& log_stream = getStartOptions().logfile_stream;
log_stream.open(filename, std::ofstream::out);
if ( log_stream.is_open() )
{
// Get the global logger object
FLog& log = *FApplication::getLog();
log.setOutputStream(log_stream);
log.enableTimestamp();
log.setLineEnding (finalcut::FLog::LF);
}
else
{
auto ftermdata = FTerm::getFTermData();
ftermdata->setExitMessage ( "Could not open log file \""
+ filename + "\"" );
exit(EXIT_FAILURE);
}
}
//----------------------------------------------------------------------
void FApplication::cmd_options (const int& argc, char* argv[])
{
// Interpret the command line options
while ( true )
{
static struct option long_options[] =
{
{"encoding", required_argument, nullptr, 0 },
{"log-file", required_argument, nullptr, 0 },
{"no-mouse", no_argument, nullptr, 0 },
{"no-optimized-cursor", no_argument, nullptr, 0 },
{"no-terminal-detection", no_argument, nullptr, 0 },
{"no-terminal-data-request", no_argument, nullptr, 0 },
{"no-color-change", no_argument, nullptr, 0 },
{"no-sgr-optimizer", no_argument, nullptr, 0 },
{"vgafont", no_argument, nullptr, 0 },
{"newfont", no_argument, nullptr, 0 },
{"dark-theme", no_argument, nullptr, 0 },
#if defined(__FreeBSD__) || defined(__DragonFly__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
{"no-cursorstyle-change", no_argument, nullptr, 0 },
#elif defined(__NetBSD__) || defined(__OpenBSD__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
#endif
{nullptr, 0, nullptr, 0 }
};
opterr = 0;
int idx{0};
const int c = getopt_long (argc, argv, "", long_options, &idx);
if ( c == -1 )
break;
if ( c == 0 )
{
if ( std::strcmp(long_options[idx].name, "encoding") == 0 )
setTerminalEncoding(FString(optarg));
if ( std::strcmp(long_options[idx].name, "log-file") == 0 )
setLogFile(FString(optarg));
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
getStartOptions().mouse_support = false;
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 )
getStartOptions().cursor_optimisation = false;
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 )
getStartOptions().terminal_detection = false;
if ( std::strcmp(long_options[idx].name, "no-terminal-data-request") == 0 )
getStartOptions().terminal_data_request = false;
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 )
getStartOptions().color_change = false;
if ( std::strcmp(long_options[idx].name, "no-sgr-optimizer") == 0 )
getStartOptions().sgr_optimizer = false;
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 )
getStartOptions().vgafont = true;
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
getStartOptions().newfont = true;
if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 )
getStartOptions().dark_theme = true;
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
getStartOptions().meta_sends_escape = false;
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
getStartOptions().change_cursorstyle = false;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
getStartOptions().meta_sends_escape = false;
#endif
}
}
}
//----------------------------------------------------------------------
inline FStartOptions& FApplication::getStartOptions()
{
return FStartOptions::getFStartOptions();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::showParameterUsage() void FApplication::showParameterUsage()
{ {
@ -321,11 +528,13 @@ void FApplication::showParameterUsage()
<< " -h, --help " << " -h, --help "
<< " Display this help and exit\n" << " Display this help and exit\n"
<< "\n" << "\n"
<< "The Final Cut options:\n" << "FINAL CUT options:\n"
<< " --encoding <name> " << " --encoding=<MODE> "
<< " Sets the character encoding mode\n" << " Sets the character encoding mode\n"
<< " " << " "
<< " {utf8, vt100, pc, ascii}\n" << " {utf8, vt100, pc, ascii}\n"
<< " --log-file=<FILE> "
<< " Writes log output to FILE\n"
<< " --no-mouse " << " --no-mouse "
<< " Disable mouse support\n" << " Disable mouse support\n"
<< " --no-optimized-cursor " << " --no-optimized-cursor "
@ -360,171 +569,6 @@ void FApplication::showParameterUsage()
#endif #endif
<< std::endl; // newline character + flushes the output stream << std::endl; // newline character + flushes the output stream
std::exit(EXIT_SUCCESS);
}
//----------------------------------------------------------------------
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
{
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 )
ev->accept();
else
{
ev->ignore();
// Status bar restore after closing the FMessageBox
if ( getStatusBar() )
getStatusBar()->drawMessage();
}
}
// private methods of FApplication
//----------------------------------------------------------------------
void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
{
// Initialize keyboard
keyboard = FTerm::getFKeyboard();
// Set the keyboard keypress timeout
if ( keyboard )
{
auto cmd1 = std::bind(&FApplication::keyPressed, this);
auto cmd2 = std::bind(&FApplication::keyReleased, this);
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
FKeyboardCommand key_cmd1 (cmd1);
FKeyboardCommand key_cmd2 (cmd2);
FKeyboardCommand key_cmd3 (cmd3);
keyboard->setPressCommand (key_cmd1);
keyboard->setReleaseCommand (key_cmd2);
keyboard->setEscPressedCommand (key_cmd3);
keyboard->setKeypressTimeout (key_time);
}
// Initialize mouse control
mouse = FTerm::getFMouseControl();
// Set stdin number for a gpm-mouse
if ( mouse )
mouse->setStdinNo (FTermios::getStdIn());
// Set the default double click interval
if ( mouse )
mouse->setDblclickInterval (dblclick_time);
// Initialize logging
getLog()->setLineEnding(FLog::CRLF);
}
//----------------------------------------------------------------------
void FApplication::cmd_options (const int& argc, char* argv[])
{
// Interpret the command line options
while ( true )
{
static struct option long_options[] =
{
{"encoding", required_argument, nullptr, 0 },
{"no-mouse", no_argument, nullptr, 0 },
{"no-optimized-cursor", no_argument, nullptr, 0 },
{"no-terminal-detection", no_argument, nullptr, 0 },
{"no-terminal-data-request", no_argument, nullptr, 0 },
{"no-color-change", no_argument, nullptr, 0 },
{"no-sgr-optimizer", no_argument, nullptr, 0 },
{"vgafont", no_argument, nullptr, 0 },
{"newfont", no_argument, nullptr, 0 },
{"dark-theme", no_argument, nullptr, 0 },
#if defined(__FreeBSD__) || defined(__DragonFly__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
{"no-cursorstyle-change", no_argument, nullptr, 0 },
#elif defined(__NetBSD__) || defined(__OpenBSD__)
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
#endif
{nullptr, 0, nullptr, 0 }
};
opterr = 0;
int idx{0};
const int c = getopt_long (argc, argv, "", long_options, &idx);
if ( c == -1 )
break;
if ( c == 0 )
{
if ( std::strcmp(long_options[idx].name, "encoding") == 0 )
{
FString encoding{optarg};
encoding = encoding.toLower();
if ( encoding.includes("utf8") )
getStartOptions().encoding = fc::UTF8;
else if ( encoding.includes("vt100") )
getStartOptions().encoding = fc::VT100;
else if ( encoding.includes("pc") )
getStartOptions().encoding = fc::PC;
else if ( encoding.includes("ascii") )
getStartOptions().encoding = fc::ASCII;
else if ( encoding.includes("help") )
showParameterUsage();
else
FTerm::exitWithMessage ( "Unknown encoding "
+ std::string(encoding.c_str()) );
}
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
getStartOptions().mouse_support = false;
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 )
getStartOptions().cursor_optimisation = false;
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 )
getStartOptions().terminal_detection = false;
if ( std::strcmp(long_options[idx].name, "no-terminal-data-request") == 0 )
getStartOptions().terminal_data_request = false;
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 )
getStartOptions().color_change = false;
if ( std::strcmp(long_options[idx].name, "no-sgr-optimizer") == 0 )
getStartOptions().sgr_optimizer = false;
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 )
getStartOptions().vgafont = true;
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
getStartOptions().newfont = true;
if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 )
getStartOptions().dark_theme = true;
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
getStartOptions().meta_sends_escape = false;
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
getStartOptions().change_cursorstyle = false;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
getStartOptions().meta_sends_escape = false;
#endif
}
}
}
//----------------------------------------------------------------------
inline FStartOptions& FApplication::getStartOptions()
{
return FStartOptions::getFStartOptions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -535,7 +579,7 @@ inline void FApplication::destroyLog()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::findKeyboardWidget() inline void FApplication::findKeyboardWidget() const
{ {
// Find the widget that has the keyboard focus // Find the widget that has the keyboard focus
@ -577,13 +621,13 @@ void FApplication::keyPressed()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::keyReleased() void FApplication::keyReleased() const
{ {
sendKeyUpEvent (keyboard_widget); sendKeyUpEvent (keyboard_widget);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::escapeKeyPressed() void FApplication::escapeKeyPressed() const
{ {
sendEscapeKeyPressEvent(); sendEscapeKeyPressEvent();
} }
@ -639,7 +683,7 @@ inline void FApplication::performKeyboardAction()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::sendEscapeKeyPressEvent() inline void FApplication::sendEscapeKeyPressEvent() const
{ {
// Send an escape key press event // Send an escape key press event
FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape); FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape);
@ -647,7 +691,7 @@ inline void FApplication::sendEscapeKeyPressEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::sendKeyDownEvent (FWidget* widget) inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
{ {
// Send key down event // Send key down event
FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey()); FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey());
@ -656,7 +700,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::sendKeyPressEvent (FWidget* widget) inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
{ {
// Send key press event // Send key press event
FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey()); FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey());
@ -665,7 +709,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::sendKeyUpEvent (FWidget* widget) inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
{ {
// Send key up event // Send key up event
FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey()); FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey());
@ -674,7 +718,7 @@ inline bool FApplication::sendKeyUpEvent (FWidget* widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::sendKeyboardAccelerator() inline void FApplication::sendKeyboardAccelerator() const
{ {
if ( FWidget::getOpenMenu() ) if ( FWidget::getOpenMenu() )
return; return;
@ -702,7 +746,7 @@ inline void FApplication::sendKeyboardAccelerator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processKeyboardEvent() void FApplication::processKeyboardEvent() const
{ {
if ( quit_now || app_exit_loop ) if ( quit_now || app_exit_loop )
return; return;
@ -717,7 +761,7 @@ void FApplication::processKeyboardEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processDialogSwitchAccelerator() bool FApplication::processDialogSwitchAccelerator() const
{ {
if ( keyboard->getKey() >= fc::Fmkey_1 if ( keyboard->getKey() >= fc::Fmkey_1
&& keyboard->getKey() <= fc::Fmkey_9 ) && keyboard->getKey() <= fc::Fmkey_9 )
@ -748,7 +792,7 @@ bool FApplication::processDialogSwitchAccelerator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processAccelerator (const FWidget* const& widget) bool FApplication::processAccelerator (const FWidget* const& widget) const
{ {
bool accpt{false}; bool accpt{false};
@ -786,7 +830,7 @@ bool FApplication::processAccelerator (const FWidget* const& widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::getMouseEvent() bool FApplication::getMouseEvent() const
{ {
bool mouse_event_occurred{false}; bool mouse_event_occurred{false};
@ -834,7 +878,7 @@ FWidget*& FApplication::determineClickedWidget()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::unsetMoveSizeMode() void FApplication::unsetMoveSizeMode() const
{ {
// Unset the move/size mode // Unset the move/size mode
@ -849,7 +893,7 @@ void FApplication::unsetMoveSizeMode()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::closeDropDown() void FApplication::closeDropDown() const
{ {
// Close the open menu // Close the open menu
@ -861,7 +905,7 @@ void FApplication::closeDropDown()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::unselectMenubarItems() void FApplication::unselectMenubarItems() const
{ {
// Unselect the menu bar items // Unselect the menu bar items
@ -897,7 +941,7 @@ void FApplication::unselectMenubarItems()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseEvent() void FApplication::sendMouseEvent() const
{ {
auto clicked = FWidget::getClickedWidget(); auto clicked = FWidget::getClickedWidget();
@ -936,7 +980,7 @@ void FApplication::sendMouseEvent()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos
, const FPoint& mouse_position , const FPoint& mouse_position
, int key_state ) , int key_state ) const
{ {
if ( ! mouse ) if ( ! mouse )
return; return;
@ -974,7 +1018,7 @@ void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
, const FPoint& mouse_position , const FPoint& mouse_position
, int key_state ) , int key_state ) const
{ {
if ( ! mouse ) if ( ! mouse )
return; return;
@ -1016,7 +1060,7 @@ void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
, const FPoint& mouse_position , const FPoint& mouse_position
, int key_state ) , int key_state ) const
{ {
if ( ! mouse ) if ( ! mouse )
return; return;
@ -1050,7 +1094,7 @@ void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
, const FPoint& mouse_position , const FPoint& mouse_position
, int key_state ) , int key_state ) const
{ {
if ( ! mouse ) if ( ! mouse )
return; return;
@ -1089,7 +1133,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::sendWheelEvent ( const FPoint& widgetMousePos void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
, const FPoint& mouse_position ) , const FPoint& mouse_position ) const
{ {
if ( ! mouse ) if ( ! mouse )
return; return;
@ -1119,6 +1163,20 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
} }
} }
//----------------------------------------------------------------------
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 ) )
{
showParameterUsage();
FApplication::exit(EXIT_SUCCESS);
}
cmd_options (argc, argv);
return nullptr;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processMouseEvent() void FApplication::processMouseEvent()
{ {
@ -1136,7 +1194,7 @@ void FApplication::processMouseEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processResizeEvent() void FApplication::processResizeEvent() const
{ {
if ( ! FTerm::hasChangedTermSize() ) if ( ! FTerm::hasChangedTermSize() )
return; return;
@ -1157,26 +1215,24 @@ void FApplication::processResizeEvent()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processCloseWidget() void FApplication::processCloseWidget()
{ {
if ( ! getWidgetCloseList() || getWidgetCloseList()->empty() )
return;
setTerminalUpdates (FVTerm::stop_terminal_updates); setTerminalUpdates (FVTerm::stop_terminal_updates);
auto iter = getWidgetCloseList()->begin();
if ( getWidgetCloseList() && ! getWidgetCloseList()->empty() ) while ( iter != getWidgetCloseList()->end() && *iter )
{ {
auto iter = getWidgetCloseList()->begin(); delete *iter;
++iter;
while ( iter != getWidgetCloseList()->end() && *iter )
{
delete *iter;
++iter;
}
getWidgetCloseList()->clear();
} }
getWidgetCloseList()->clear();
setTerminalUpdates (FVTerm::start_terminal_updates); setTerminalUpdates (FVTerm::start_terminal_updates);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processLogger() void FApplication::processLogger() const
{ {
// Synchronizing the stream buffer with the logging output // Synchronizing the stream buffer with the logging output
@ -1184,23 +1240,37 @@ void FApplication::processLogger()
if ( ! logger->str().empty() ) if ( ! logger->str().empty() )
logger->pubsync(); logger->pubsync();
logger->flush();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processNextEvent() bool FApplication::processNextEvent()
{ {
uInt num_events{0}; uInt num_events{0};
bool is_timeout = isNextEventTimeout();
if ( is_timeout )
{
FObject::getCurrentTime (&time_last_event);
processKeyboardEvent();
processMouseEvent();
processResizeEvent();
processTerminalUpdate();
processCloseWidget();
processLogger();
updateTerminal();
}
processKeyboardEvent();
processMouseEvent();
processResizeEvent();
processTerminalUpdate();
processCloseWidget();
processLogger();
processExternalUserEvent(); processExternalUserEvent();
sendQueuedEvents(); if ( is_timeout )
num_events += processTimerEvent(); {
sendQueuedEvents();
num_events += processTimerEvent();
uInt64 wait{next_event_wait / 2};
std::this_thread::sleep_for(std::chrono::microseconds(wait));
}
return ( num_events > 0 ); return ( num_events > 0 );
} }
@ -1266,4 +1336,10 @@ bool FApplication::isEventProcessable ( const FObject* receiver
return true; return true;
} }
//----------------------------------------------------------------------
bool FApplication::isNextEventTimeout()
{
return FObject::isTimeout (&time_last_event, next_event_wait);
}
} // namespace finalcut } // namespace finalcut

126
src/fbusyindicator.cpp Normal file
View File

@ -0,0 +1,126 @@
/***********************************************************************
* fbusyindicator.cpp - Shows background activity *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 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 *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fbusyindicator.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FBusyIndicator
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FBusyIndicator::FBusyIndicator (FWidget* parent)
: FToolTip{parent}
{
init();
}
//----------------------------------------------------------------------
FBusyIndicator::~FBusyIndicator() // destructor
{ }
// public methods of FBusyIndicator
//----------------------------------------------------------------------
void FBusyIndicator::start()
{
running = true;
createIndicatorText();
show();
updateTerminal();
flush();
addTimer(TIMER);
}
//----------------------------------------------------------------------
void FBusyIndicator::stop()
{
delOwnTimers();
running = false;
hide();
updateTerminal();
flush();
}
// private methods of FBusyIndicator
//----------------------------------------------------------------------
void FBusyIndicator::init()
{
FToolTip::hide();
}
//----------------------------------------------------------------------
void FBusyIndicator::createIndicatorText()
{
FString line[4]{};
if ( FTerm::getEncoding() == fc::UTF8 )
{
const wchar_t (&p)[8] = uni_pattern;
line[0] << " " << p[7] << " " << p[0] << " \n";
line[1] << " " << p[6] << " " << p[1] << " \n";
line[2] << " " << p[5] << " " << p[2] << " \n";
line[3] << " " << p[4] << " " << p[3] << " ";
}
else
{
const char (&p)[8] = pattern;
line[0] << " " << p[7] << " " << p[0] << " \n";
line[1] << " " << p[6] << " " << p[1] << " \n";
line[2] << " " << p[5] << " " << p[2] << " \n";
line[3] << " " << p[4] << " " << p[3] << " ";
}
FString txt{line[0] + line[1] + line[2] + line[3]};
FToolTip::setText(txt);
}
//----------------------------------------------------------------------
void FBusyIndicator::onTimer (finalcut::FTimerEvent*)
{
// Rotate pattern
if ( FTerm::getEncoding() == fc::UTF8 )
{
const wchar_t last = uni_pattern[7];
std::memmove(uni_pattern + 1, uni_pattern , sizeof(wchar_t) * 7);
uni_pattern[0] = last;
}
else
{
const char last = pattern[7];
std::memmove(pattern + 1, pattern , sizeof(char) * 7);
pattern[0] = last;
}
// Redraw the rotated pattern
createIndicatorText();
redraw();
updateTerminal();
flush();
}
} // namespace finalcut

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fbutton.cpp - Widget FButton * * fbutton.cpp - Widget FButton *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -53,7 +53,7 @@ FButton::FButton (const FString& txt, FWidget* parent)
FButton::~FButton() // destructor FButton::~FButton() // destructor
{ {
delAccelerator(); delAccelerator();
delOwnTimer(); delOwnTimers();
} }
// FButton operator // FButton operator
@ -353,7 +353,7 @@ void FButton::onAccel (FAccelEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = ev->focusedWidget();
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -402,8 +402,9 @@ void FButton::onFocusOut (FFocusEvent*)
void FButton::init() void FButton::init()
{ {
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setForegroundColor (wc->button_active_fg); button_fg = wc->button_active_fg;
setBackgroundColor (wc->button_active_bg); button_bg = wc->button_active_bg;
resetColors();
setShadow(); setShadow();
if ( ! text.isEmpty() ) if ( ! text.isEmpty() )
@ -669,7 +670,7 @@ void FButton::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::updateStatusBar() void FButton::updateStatusBar() const
{ {
if ( ! getFlags().focus || ! getStatusBar() ) if ( ! getFlags().focus || ! getStatusBar() )
return; return;
@ -708,7 +709,7 @@ void FButton::updateButtonColor()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::processClick() void FButton::processClick() const
{ {
emitCallback("clicked"); emitCallback("clicked");
} }

View File

@ -2,17 +2,17 @@
* fbuttongroup.cpp - The FButtonGroup widget organizes FToggleButton * * fbuttongroup.cpp - The FButtonGroup widget organizes FToggleButton *
* widgets in a group. * * widgets in a group. *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -240,11 +240,11 @@ void FButtonGroup::insert (FToggleButton* button)
button->addCallback button->addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &FButtonGroup::cb_buttonToggled) this, &FButtonGroup::cb_buttonToggled,
button
); );
} }
//----------------------------------------------------------------------
void FButtonGroup::remove (FToggleButton* button) void FButtonGroup::remove (FToggleButton* button)
{ {
if ( ! button || buttonlist.empty() ) if ( ! button || buttonlist.empty() )
@ -542,10 +542,8 @@ void FButtonGroup::directFocus()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::cb_buttonToggled (FWidget* widget, const FDataPtr) void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const
{ {
const auto& button = static_cast<FToggleButton*>(widget);
if ( (button && ! button->isChecked()) || buttonlist.empty() ) if ( (button && ! button->isChecked()) || buttonlist.empty() )
return; return;

89
src/fcallback.cpp Normal file
View File

@ -0,0 +1,89 @@
/***********************************************************************
* fcallback.cpp - Implements the callback functionality *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 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 *
* published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. *
* *
* FINAL CUT is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fcallback.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FCallback
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FCallback::FCallback()
{ }
//----------------------------------------------------------------------
FCallback::~FCallback() // destructor
{ }
// public methods of FCallback
//----------------------------------------------------------------------
void FCallback::delCallback (const FString& cb_signal)
{
// Deletes entries with the given signal from the callback list
if ( callback_objects.empty() )
return;
auto iter = callback_objects.begin();
while ( iter != callback_objects.end() )
{
if ( iter->cb_signal == cb_signal )
iter = callback_objects.erase(iter);
else
++iter;
}
}
//----------------------------------------------------------------------
void FCallback::delCallback()
{
// Delete all callbacks from this widget
callback_objects.clear(); // function pointer
}
//----------------------------------------------------------------------
void FCallback::emitCallback (const FString& emit_signal) const
{
// Initiate callback for the given signal
if ( callback_objects.empty() )
return;
for (auto&& cback : callback_objects)
{
if ( cback.cb_signal == emit_signal )
{
// Calling the stored function pointer
cback.cb_function();
}
}
}
} // namespace finalcut

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fcharmap.cpp - Character mapping and encoding * * fcharmap.cpp - Character mapping and encoding *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2019 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fcheckbox.cpp - Widget FCheckBox * * fcheckbox.cpp - Widget FCheckBox *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -74,7 +74,7 @@ void FCheckBox::draw()
void FCheckBox::drawCheckButton() void FCheckBox::drawCheckButton()
{ {
print() << FPoint{1, 1}; print() << FPoint{1, 1};
useParentWidgetColor(); setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fcheckmenuitem.cpp - Widget FCheckMenuItem * * fcheckmenuitem.cpp - Widget FCheckMenuItem *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -36,14 +36,14 @@ namespace finalcut
FCheckMenuItem::FCheckMenuItem (FWidget* parent) FCheckMenuItem::FCheckMenuItem (FWidget* parent)
: FMenuItem{parent} : FMenuItem{parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent) FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent)
: FMenuItem{txt, parent} : FMenuItem{txt, parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -53,9 +53,10 @@ FCheckMenuItem::~FCheckMenuItem() // destructor
// private methods of FCheckMenuItem // private methods of FCheckMenuItem
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FCheckMenuItem::init (FWidget* parent) void FCheckMenuItem::init()
{ {
setCheckable(); setCheckable();
FWidget* parent = getParentWidget();
if ( ! parent ) if ( ! parent )
return; return;
@ -68,7 +69,7 @@ void FCheckMenuItem::init (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FCheckMenuItem::processToggle() void FCheckMenuItem::processToggle() const
{ {
emitCallback("toggled"); emitCallback("toggled");
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fcolorpalette.cpp - Define RGB color value for a palette entry * * fcolorpalette.cpp - Define RGB color value for a palette entry *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -42,21 +42,21 @@ FColorPalette::~FColorPalette() // destructor
// protected methods of FColorPalette // protected methods of FColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FColorPalette::setPalette (FColor index, int r, int g, int b) void FColorPalette::setPalette (FColor index, int r, int g, int b) const
{ {
set_palette (index, r, g, b); set_palette (index, r, g, b);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FColorPalette::setVGAdefaultPalette() void FColorPalette::setVGAdefaultPalette() const
{ {
setPalette (fc::Black, 0x00, 0x00, 0x00); setPalette (fc::Black, 0x00, 0x00, 0x00);
setPalette (fc::Blue, 0x00, 0x00, 0xaa); setPalette (fc::Blue, 0x00, 0x00, 0xaa);
setPalette (fc::Green, 0x00, 0xaa, 0x00); setPalette (fc::Green, 0x00, 0xaa, 0x00);
setPalette (fc::Cyan, 0x00, 0x55, 0xaa); setPalette (fc::Cyan, 0x00, 0xaa, 0xaa);
setPalette (fc::Red, 0xaa, 0x00, 0x00); setPalette (fc::Red, 0xaa, 0x00, 0x00);
setPalette (fc::Magenta, 0xaa, 0x00, 0xaa); setPalette (fc::Magenta, 0xaa, 0x00, 0xaa);
setPalette (fc::Brown, 0xaa, 0xaa, 0x00); setPalette (fc::Brown, 0xaa, 0x55, 0x00);
setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa); setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa);
setPalette (fc::DarkGray, 0x55, 0x55, 0x55); setPalette (fc::DarkGray, 0x55, 0x55, 0x55);
setPalette (fc::LightBlue, 0x55, 0x55, 0xff); setPalette (fc::LightBlue, 0x55, 0x55, 0xff);
@ -126,7 +126,7 @@ default16ColorPalette::default16ColorPalette (const FSetPalette& f)
default16ColorPalette::~default16ColorPalette() default16ColorPalette::~default16ColorPalette()
{ } { }
// public methods of default8ColorPalette // public methods of default16ColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void default16ColorPalette::setColorPalette() void default16ColorPalette::setColorPalette()
{ {
@ -169,7 +169,7 @@ default16DarkColorPalette::default16DarkColorPalette (const FSetPalette& f)
default16DarkColorPalette::~default16DarkColorPalette() default16DarkColorPalette::~default16DarkColorPalette()
{ } { }
// public methods of default8ColorPalette // public methods of default16DarkColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void default16DarkColorPalette::setColorPalette() void default16DarkColorPalette::setColorPalette()
{ {
@ -180,7 +180,7 @@ void default16DarkColorPalette::setColorPalette()
setPalette (fc::Red, 0xa5, 0x40, 0x40); setPalette (fc::Red, 0xa5, 0x40, 0x40);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f); setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xd2, 0xd2, 0xd2); setPalette (fc::LightGray, 0xdc, 0xdc, 0xdc);
setPalette (fc::DarkGray, 0x27, 0x33, 0x39); setPalette (fc::DarkGray, 0x27, 0x33, 0x39);
setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8); setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8);
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c); setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fcombobox.cpp - Widget FComboBox * * fcombobox.cpp - Widget FComboBox *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <memory>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fcolorpair.h" #include "final/fcolorpair.h"
#include "final/fcombobox.h" #include "final/fcombobox.h"
@ -124,8 +126,11 @@ void FDropDownListBox::init()
void FDropDownListBox::draw() void FDropDownListBox::draw()
{ {
// Fill the background // Fill the background
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setColor (wc->menu_active_fg, wc->menu_active_bg); setForegroundColor (wc->list_fg);
setBackgroundColor (wc->list_bg);
setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(true); setReverse(true);
@ -505,19 +510,19 @@ void FComboBox::initCallbacks()
input_field.addCallback input_field.addCallback
( (
"mouse-press", "mouse-press",
F_METHOD_CALLBACK (this, &FComboBox::cb_inputFieldSwitch) this, &FComboBox::cb_inputFieldSwitch
); );
input_field.addCallback input_field.addCallback
( (
"mouse-move", "mouse-move",
F_METHOD_CALLBACK (this, &FComboBox::cb_inputFieldHandOver) this, &FComboBox::cb_inputFieldHandOver
); );
list_window.list.addCallback list_window.list.addCallback
( (
"row-changed", "row-changed",
F_METHOD_CALLBACK (this, &FComboBox::cb_setInputField) this, &FComboBox::cb_setInputField
); );
for (const auto& signal : {"row-selected", "clicked"}) for (const auto& signal : {"row-selected", "clicked"})
@ -525,7 +530,7 @@ void FComboBox::initCallbacks()
list_window.list.addCallback list_window.list.addCallback
( (
signal, signal,
F_METHOD_CALLBACK (this, &FComboBox::cb_closeComboBox) this, &FComboBox::cb_closeComboBox
); );
} }
} }
@ -548,10 +553,10 @@ void FComboBox::draw()
print() << FPoint{int(getWidth()) - nf, 1} print() << FPoint{int(getWidth()) - nf, 1}
<< button_color; << button_color;
if ( FTerm::isNewFont() ) if ( FTerm::isNewFont() )
print() << NF_button_arrow_down; print() << NF_button_arrow_down;
else else
print() << fc::BlackDownPointingTriangle; // ▼ print() << fc::BlackDownPointingTriangle; // ▼
if ( getFlags().shadow ) if ( getFlags().shadow )
drawShadow(this); drawShadow(this);
@ -613,19 +618,19 @@ void FComboBox::passEventToListWindow (FMouseEvent* const& ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::processClick() void FComboBox::processClick() const
{ {
emitCallback("clicked"); emitCallback("clicked");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::processChanged() void FComboBox::processChanged() const
{ {
emitCallback("row-changed"); emitCallback("row-changed");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_setInputField (const FWidget*, const FDataPtr) void FComboBox::cb_setInputField()
{ {
auto& list = list_window.list; auto& list = list_window.list;
const std::size_t index = list.currentItem(); const std::size_t index = list.currentItem();
@ -635,14 +640,14 @@ void FComboBox::cb_setInputField (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_closeComboBox (const FWidget*, const FDataPtr) void FComboBox::cb_closeComboBox()
{ {
hideDropDown(); hideDropDown();
processClick(); processClick();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_inputFieldSwitch (const FWidget*, const FDataPtr) void FComboBox::cb_inputFieldSwitch()
{ {
const auto& mouse = FTerm::getFMouseControl(); const auto& mouse = FTerm::getFMouseControl();
@ -674,7 +679,7 @@ void FComboBox::cb_inputFieldSwitch (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_inputFieldHandOver (const FWidget*, const FDataPtr) void FComboBox::cb_inputFieldHandOver()
{ {
const auto& mouse = FTerm::getFMouseControl(); const auto& mouse = FTerm::getFMouseControl();

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fdialog.cpp - Widget FDialog * * fdialog.cpp - Widget FDialog *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -166,7 +166,7 @@ void FDialog::show()
FWindow::show(); FWindow::show();
if ( isModal() ) if ( isModal() && ! FApplication::isQuit() )
{ {
auto fapp = FApplication::getApplicationObject(); auto fapp = FApplication::getApplicationObject();
fapp->enterLoop(); fapp->enterLoop();
@ -873,7 +873,8 @@ void FDialog::initMoveSizeMenuItem (FMenu* menu)
move_size_item->addCallback move_size_item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FDialog::cb_move) this,
&FDialog::cb_move
); );
} }
@ -896,7 +897,8 @@ void FDialog::initZoomMenuItem (FMenu* menu)
zoom_item->addCallback zoom_item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FDialog::cb_zoom) this,
&FDialog::cb_zoom
); );
} }
@ -918,7 +920,8 @@ void FDialog::initCloseMenuItem (FMenu* menu)
close_item->addCallback close_item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FDialog::cb_close) this,
&FDialog::cb_close
); );
} }
@ -1270,7 +1273,7 @@ void FDialog::setZoomItem()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FDialog::getZoomButtonWidth() inline std::size_t FDialog::getZoomButtonWidth() const
{ {
if ( ! isResizeable() ) if ( ! isResizeable() )
return 0; return 0;
@ -1632,7 +1635,7 @@ void FDialog::delDialog (const FWidget* obj)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::cb_move (const FWidget*, const FDataPtr) void FDialog::cb_move()
{ {
if ( isZoomed() ) if ( isZoomed() )
return; return;
@ -1683,7 +1686,7 @@ void FDialog::cb_move (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::cb_zoom (const FWidget*, const FDataPtr) void FDialog::cb_zoom()
{ {
dialog_menu->unselectItem(); dialog_menu->unselectItem();
dialog_menu->hide(); dialog_menu->hide();
@ -1694,7 +1697,7 @@ void FDialog::cb_zoom (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::cb_close (const FWidget*, const FDataPtr) void FDialog::cb_close()
{ {
dialog_menu->unselectItem(); dialog_menu->unselectItem();
dialog_menu->hide(); dialog_menu->hide();

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fdialoglistmenu.cpp - Widget FDialogListMenu * * fdialoglistmenu.cpp - Widget FDialogListMenu *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fevent.cpp - Base event class of widgets * * fevent.cpp - Base event class of widgets *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -235,7 +235,7 @@ void FFocusEvent::ignore()
// class FAccelEvent // class FAccelEvent
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor
: FEvent{ev_type} : FEvent{ev_type}
, focus_widget{focused} , focus_widget{focused}
{ } { }
@ -245,7 +245,7 @@ FAccelEvent::~FAccelEvent() // destructor
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void* FAccelEvent::focusedWidget() const FWidget* FAccelEvent::focusedWidget() const
{ return focus_widget; } { return focus_widget; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* ffiledialog.cpp - Widget FFileDialog (a file chooser dialog) * * ffiledialog.cpp - Widget FFileDialog (a file chooser dialog) *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -201,7 +201,7 @@ void FFileDialog::setPath (const FString& dir)
return; return;
} }
if ( fsystem->realpath(dir.c_str(), resolved_path) != nullptr ) if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path) != nullptr )
r_dir.setString(resolved_path); r_dir.setString(resolved_path);
else else
r_dir.setString(dir); r_dir.setString(dir);
@ -380,43 +380,43 @@ void FFileDialog::initCallbacks()
filename.addCallback filename.addCallback
( (
"activate", "activate",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processActivate) this, &FFileDialog::cb_processActivate
); );
filebrowser.addCallback filebrowser.addCallback
( (
"row-changed", "row-changed",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processRowChanged) this, &FFileDialog::cb_processRowChanged
); );
filebrowser.addCallback filebrowser.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processClicked) this, &FFileDialog::cb_processClicked
); );
hidden_check.addCallback hidden_check.addCallback
( (
"toggled", "toggled",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processShowHidden) this, &FFileDialog::cb_processShowHidden
); );
cancel_btn.addCallback cancel_btn.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processCancel) this, &FFileDialog::cb_processCancel
); );
open_btn.addCallback open_btn.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FFileDialog::cb_processOpen) this, &FFileDialog::cb_processOpen
); );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FFileDialog::pattern_match ( const char* const pattern inline bool FFileDialog::patternMatch ( const char* const pattern
, const char fname[] ) , const char fname[] ) const
{ {
char search[128]{}; char search[128]{};
@ -583,14 +583,14 @@ void FFileDialog::getEntry (const char* const dir, const struct dirent* d_entry)
if ( entry.directory ) if ( entry.directory )
dir_entries.push_back (entry); dir_entries.push_back (entry);
else if ( pattern_match(filter, entry.name.c_str()) ) else if ( patternMatch(filter, entry.name.c_str()) )
dir_entries.push_back (entry); dir_entries.push_back (entry);
else else
entry.name.clear(); entry.name.clear();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
{ {
if ( ! entry.symbolic_link ) if ( ! entry.symbolic_link )
return; // No symbolic link return; // No symbolic link
@ -754,7 +754,7 @@ const FString FFileDialog::getHomeDir()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processActivate (const FWidget*, const FDataPtr) void FFileDialog::cb_processActivate()
{ {
if ( filename.getText().includes('*') if ( filename.getText().includes('*')
|| filename.getText().includes('?') ) || filename.getText().includes('?') )
@ -803,7 +803,7 @@ void FFileDialog::cb_processActivate (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processRowChanged (const FWidget*, const FDataPtr) void FFileDialog::cb_processRowChanged()
{ {
const std::size_t n = filebrowser.currentItem(); const std::size_t n = filebrowser.currentItem();
@ -821,7 +821,7 @@ void FFileDialog::cb_processRowChanged (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processClicked (const FWidget*, const FDataPtr) void FFileDialog::cb_processClicked()
{ {
const uLong n = uLong(filebrowser.currentItem() - 1); const uLong n = uLong(filebrowser.currentItem() - 1);
@ -832,19 +832,19 @@ void FFileDialog::cb_processClicked (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processCancel (const FWidget*, const FDataPtr) void FFileDialog::cb_processCancel()
{ {
done (FDialog::Reject); done (FDialog::Reject);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processOpen (const FWidget*, const FDataPtr) void FFileDialog::cb_processOpen()
{ {
done (FDialog::Accept); done (FDialog::Accept);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FFileDialog::cb_processShowHidden (const FWidget*, const FDataPtr) void FFileDialog::cb_processShowHidden()
{ {
setShowHiddenFiles(! show_hidden); setShowHiddenFiles(! show_hidden);
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fkey_map.cpp - Key name mapping * * fkey_map.cpp - Key name mapping *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fkeyboard.cpp - Read keyboard events * * fkeyboard.cpp - Read keyboard events *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -42,9 +42,11 @@ namespace finalcut
{ {
// static class attributes // static class attributes
uInt64 FKeyboard::read_blocking_time{100000}; // preset to 100 ms uInt64 FKeyboard::read_blocking_time{100000}; // preset to 100 ms / 10 Hz
uInt64 FKeyboard::key_timeout{100000}; // preset to 100 ms uInt64 FKeyboard::key_timeout{100000}; // preset to 100 ms / 10 Hz
uInt64 FKeyboard::interval_timeout{75000}; // preset to 75 ms / 13.3 Hz
struct timeval FKeyboard::time_keypressed{}; struct timeval FKeyboard::time_keypressed{};
struct timeval FKeyboard::time_last_request{};
#if defined(__linux__) #if defined(__linux__)
FTermLinux* FKeyboard::linux{nullptr}; FTermLinux* FKeyboard::linux{nullptr};
@ -62,6 +64,8 @@ FKeyboard::FKeyboard()
// Initialize keyboard values // Initialize keyboard values
time_keypressed.tv_sec = 0; time_keypressed.tv_sec = 0;
time_keypressed.tv_usec = 0; time_keypressed.tv_usec = 0;
time_last_request.tv_sec = 0;
time_last_request.tv_usec = 0;
// Get the stdin file status flags // Get the stdin file status flags
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL); stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
@ -82,7 +86,7 @@ void FKeyboard::fetchKeyCode()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString FKeyboard::getKeyName (const FKey keynum) const FString FKeyboard::getKeyName (const FKey keynum) const
{ {
for (std::size_t i{0}; fc::fkeyname[i].string[0] != 0; i++) for (std::size_t i{0}; fc::fkeyname[i].string[0] != 0; i++)
if ( fc::fkeyname[i].num && fc::fkeyname[i].num == keynum ) if ( fc::fkeyname[i].num && fc::fkeyname[i].num == keynum )
@ -117,6 +121,9 @@ bool& FKeyboard::unprocessedInput()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FKeyboard::isKeyPressed() const bool FKeyboard::isKeyPressed() const
{ {
if ( ! isIntervalTimeout() )
return false;
fd_set ifds{}; fd_set ifds{};
struct timeval tv{}; struct timeval tv{};
const int stdin_no = FTermios::getStdIn(); const int stdin_no = FTermios::getStdIn();
@ -124,7 +131,8 @@ bool FKeyboard::isKeyPressed() const
FD_ZERO(&ifds); FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = suseconds_t(FKeyboard::read_blocking_time); // preset to 100 ms tv.tv_usec = suseconds_t(read_blocking_time); // preset to 100 ms
FObject::getCurrentTime (&time_last_request);
const int result = select (stdin_no + 1, &ifds, nullptr, nullptr, &tv); const int result = select (stdin_no + 1, &ifds, nullptr, nullptr, &tv);
if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
@ -179,7 +187,7 @@ void FKeyboard::escapeKeyHandling()
// private methods of FKeyboard // private methods of FKeyboard
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FKey FKeyboard::getMouseProtocolKey() inline FKey FKeyboard::getMouseProtocolKey() const
{ {
// Looking for mouse string in the key buffer // Looking for mouse string in the key buffer
@ -351,13 +359,19 @@ bool FKeyboard::setNonBlockingInput (bool enable)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FKeyboard::isKeypressTimeout() inline bool FKeyboard::isKeypressTimeout()
{ {
return FObject::isTimeout (&time_keypressed, key_timeout); return FObject::isTimeout (&time_keypressed, key_timeout);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FKey FKeyboard::UTF8decode (const char utf8[]) inline bool FKeyboard::isIntervalTimeout()
{
return FObject::isTimeout (&time_last_request, interval_timeout);
}
//----------------------------------------------------------------------
FKey FKeyboard::UTF8decode (const char utf8[]) const
{ {
FKey ucs{0}; // Universal coded character FKey ucs{0}; // Universal coded character
constexpr std::size_t max = 4; constexpr std::size_t max = 4;
@ -488,7 +502,7 @@ FKey FKeyboard::parseKeyString()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FKey FKeyboard::keyCorrection (const FKey& keycode) FKey FKeyboard::keyCorrection (const FKey& keycode) const
{ {
FKey key_correction; FKey key_correction;
@ -535,19 +549,19 @@ void FKeyboard::substringKeyHandling()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FKeyboard::keyPressed() void FKeyboard::keyPressed() const
{ {
keypressed_cmd.execute(); keypressed_cmd.execute();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FKeyboard::keyReleased() void FKeyboard::keyReleased() const
{ {
keyreleased_cmd.execute(); keyreleased_cmd.execute();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FKeyboard::escapeKeyPressed() void FKeyboard::escapeKeyPressed() const
{ {
escape_key_cmd.execute(); escape_key_cmd.execute();
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flabel.cpp - Widget FLabel * * flabel.cpp - Widget FLabel *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -83,7 +83,7 @@ FLabel& FLabel::operator << (const wchar_t c)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FLabel& FLabel::operator >> (FString& s) const FLabel& FLabel::operator >> (FString& s) const
{ {
s += text; s += text;
return *this; return *this;
@ -100,7 +100,7 @@ void FLabel::setAccelWidget (FWidget* widget)
accel_widget->addCallback accel_widget->addCallback
( (
"destroy", "destroy",
F_METHOD_CALLBACK (this, &FLabel::cb_accelWidgetDestroyed) this, &FLabel::cb_accelWidgetDestroyed
); );
} }
@ -115,6 +115,15 @@ void FLabel::setAlignment (fc::text_alignment align)
alignment = align; alignment = align;
} }
//----------------------------------------------------------------------
void FLabel::resetColors()
{
useParentWidgetColor();
const auto& wc = getColorTheme();
emphasis_color = wc->label_emphasis_fg;
ellipsis_color = wc->label_ellipsis_fg;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FLabel::setEnable (bool enable) bool FLabel::setEnable (bool enable)
{ {
@ -212,7 +221,7 @@ void FLabel::onAccel (FAccelEvent* ev)
if ( ! accel_widget->hasFocus() ) if ( ! accel_widget->hasFocus() )
{ {
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = ev->focusedWidget();
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -235,7 +244,7 @@ void FLabel::onAccel (FAccelEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::cb_accelWidgetDestroyed (const FWidget*, const FDataPtr) void FLabel::cb_accelWidgetDestroyed()
{ {
accel_widget = nullptr; accel_widget = nullptr;
delAccelerator(); delAccelerator();
@ -247,6 +256,7 @@ void FLabel::cb_accelWidgetDestroyed (const FWidget*, const FDataPtr)
void FLabel::init() void FLabel::init()
{ {
unsetFocusable(); unsetFocusable();
resetColors();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -256,7 +266,7 @@ void FLabel::setHotkeyAccelerator()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FLabel::getAlignOffset (const std::size_t length) std::size_t FLabel::getAlignOffset (const std::size_t length) const
{ {
const std::size_t width(getWidth()); const std::size_t width(getWidth());
assert ( alignment == fc::alignLeft assert ( alignment == fc::alignLeft
@ -290,8 +300,6 @@ void FLabel::draw()
if ( text.isEmpty() ) if ( text.isEmpty() )
return; return;
useParentWidgetColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {
setReverse(true); setReverse(true);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flineedit.cpp - Widget FLineEdit * * flineedit.cpp - Widget FLineEdit *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -88,7 +88,7 @@ FLineEdit& FLineEdit::operator << (const wchar_t c)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FLineEdit& FLineEdit::operator >> (FString& s) const FLineEdit& FLineEdit::operator >> (FString& s) const
{ {
s += text; s += text;
return *this; return *this;
@ -405,7 +405,7 @@ void FLineEdit::onMouseUp (FMouseEvent*)
{ {
if ( drag_scroll != FLineEdit::noScroll ) if ( drag_scroll != FLineEdit::noScroll )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
scroll_timer = false; scroll_timer = false;
} }
@ -446,7 +446,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
if ( text_offset == 0 ) if ( text_offset == 0 )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
} }
@ -462,14 +462,14 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
if ( cursor_pos == len ) if ( cursor_pos == len )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
} }
else else
{ {
// no dragging // no dragging
delOwnTimer(); delOwnTimers();
scroll_timer = false; scroll_timer = false;
drag_scroll = FLineEdit::noScroll; drag_scroll = FLineEdit::noScroll;
} }
@ -544,7 +544,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
if ( ! hasFocus() ) if ( ! hasFocus() )
{ {
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = ev->focusedWidget();
if ( focused_widget && focused_widget->isWidget() ) if ( focused_widget && focused_widget->isWidget() )
{ {
@ -661,7 +661,7 @@ void FLineEdit::init()
bool FLineEdit::hasHotkey() const bool FLineEdit::hasHotkey() const
{ {
if ( label_text.isEmpty() ) if ( label_text.isEmpty() )
return 0; return false;
return label_text.includes('&'); return label_text.includes('&');
} }
@ -787,7 +787,7 @@ inline std::size_t FLineEdit::printPassword()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FLineEdit::getCursorColumnPos() inline std::size_t FLineEdit::getCursorColumnPos() const
{ {
if ( input_type == FLineEdit::textfield ) if ( input_type == FLineEdit::textfield )
{ {
@ -1104,7 +1104,7 @@ inline bool FLineEdit::keyInput (FKey key)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline wchar_t FLineEdit::characterFilter (const wchar_t c) inline wchar_t FLineEdit::characterFilter (const wchar_t c) const
{ {
if ( input_filter.empty() ) if ( input_filter.empty() )
return c; return c;
@ -1130,7 +1130,7 @@ void FLineEdit::processActivate()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::processChanged() void FLineEdit::processChanged() const
{ {
emitCallback("changed"); emitCallback("changed");
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flistbox.cpp - Widget FListBox and FListBoxItem * * flistbox.cpp - Widget FListBox and FListBoxItem *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -95,7 +95,7 @@ FListBox::FListBox (FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListBox::~FListBox() // destructor FListBox::~FListBox() // destructor
{ {
delOwnTimer(); delOwnTimers();
} }
@ -572,7 +572,7 @@ void FListBox::onFocusOut (FFocusEvent*)
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
} }
delOwnTimer(); delOwnTimers();
inc_search.clear(); inc_search.clear();
} }
@ -644,7 +644,7 @@ void FListBox::adjustSize()
// private methods of FListBox // private methods of FListBox
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString& FListBox::getString (listBoxItems::iterator iter) inline FString FListBox::getString (listBoxItems::iterator iter)
{ {
return iter->getText(); return iter->getText();
} }
@ -721,7 +721,6 @@ void FListBox::draw()
useParentWidgetColor(); useParentWidgetColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(true); setReverse(true);
@ -767,7 +766,7 @@ void FListBox::drawBorder()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::drawScrollbars() void FListBox::drawScrollbars() const
{ {
if ( ! hbar->isShown() && isHorizontallyScrollable() ) if ( ! hbar->isShown() && isHorizontallyScrollable() )
hbar->show(); hbar->show();
@ -1062,7 +1061,7 @@ inline void FListBox::setLineAttributes ( int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListBox::unsetAttributes() inline void FListBox::unsetAttributes() const
{ {
if ( FTerm::isMonochron() ) // unset for the last element if ( FTerm::isMonochron() ) // unset for the last element
setReverse(false); setReverse(false);
@ -1121,7 +1120,7 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::recalculateVerticalBar (std::size_t element_count) void FListBox::recalculateVerticalBar (std::size_t element_count) const
{ {
const int vmax = ( element_count + 2 > getHeight() ) const int vmax = ( element_count + 2 > getHeight() )
? int(element_count - getHeight() + 2) ? int(element_count - getHeight() + 2)
@ -1307,7 +1306,7 @@ void FListBox::dragUp (int mouse_button)
if ( current == 1 ) if ( current == 1 )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
} }
} }
@ -1332,7 +1331,7 @@ void FListBox::dragDown (int mouse_button)
if ( current == getCount() ) if ( current == getCount() )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
} }
} }
@ -1340,7 +1339,7 @@ void FListBox::dragDown (int mouse_button)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::stopDragScroll() void FListBox::stopDragScroll()
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
scroll_distance = 1; scroll_distance = 1;
scroll_timer = false; scroll_timer = false;
@ -1697,25 +1696,25 @@ inline bool FListBox::keyIncSearchInput (FKey key)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::processClick() void FListBox::processClick() const
{ {
emitCallback("clicked"); emitCallback("clicked");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::processSelect() void FListBox::processSelect() const
{ {
emitCallback("row-selected"); emitCallback("row-selected");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::processChanged() void FListBox::processChanged() const
{ {
emitCallback("row-changed"); emitCallback("row-changed");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::changeOnResize() void FListBox::changeOnResize() const
{ {
if ( FTerm::isNewFont() ) if ( FTerm::isNewFont() )
{ {
@ -1744,7 +1743,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_vbarChange (const FWidget*, const FDataPtr) void FListBox::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType; FScrollbar::sType scrollType;
const std::size_t current_before = current; const std::size_t current_before = current;
@ -1815,7 +1814,7 @@ void FListBox::cb_vbarChange (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_hbarChange (const FWidget*, const FDataPtr) void FListBox::cb_hbarChange (const FWidget*)
{ {
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flistview.cpp - Widget FListView and FListViewItem * * flistview.cpp - Widget FListView and FListViewItem *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -24,8 +24,10 @@
#include <strings.h> // need for strcasecmp #include <strings.h> // need for strcasecmp
#endif #endif
#include <limits>
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#include <utility>
#include <vector> #include <vector>
#include "final/emptyfstring.h" #include "final/emptyfstring.h"
@ -310,7 +312,7 @@ FObject::iterator FListViewItem::insert (FListViewItem* child)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::iterator FListViewItem::insert ( FListViewItem* child FObject::iterator FListViewItem::insert ( FListViewItem* child
, iterator parent_iter ) , iterator parent_iter ) const
{ {
if ( parent_iter == FListView::getNullIterator() ) if ( parent_iter == FListView::getNullIterator() )
return FListView::getNullIterator(); return FListView::getNullIterator();
@ -335,7 +337,7 @@ FObject::iterator FListViewItem::insert ( FListViewItem* child
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListViewItem::remove (FListViewItem* item) void FListViewItem::remove (FListViewItem* item) const
{ {
if ( item == nullptr || item == *FListView::getNullIterator() ) if ( item == nullptr || item == *FListView::getNullIterator() )
return; return;
@ -691,12 +693,12 @@ FListView::FListView (FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListView::~FListView() // destructor FListView::~FListView() // destructor
{ {
delOwnTimer(); delOwnTimers();
} }
// public methods of FListView // public methods of FListView
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FListView::getCount() std::size_t FListView::getCount() const
{ {
int n{0}; int n{0};
@ -1282,12 +1284,11 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
const int mouse_x = ev->getX(); const int mouse_x = ev->getX();
const int mouse_y = ev->getY(); const int mouse_y = ev->getY();
const std::size_t element_count = getCount();
if ( mouse_x > 1 && mouse_x < int(getWidth()) if ( mouse_x > 1 && mouse_x < int(getWidth())
&& mouse_y > 1 && mouse_y < int(getHeight()) ) && mouse_y > 1 && mouse_y < int(getHeight()) )
{ {
if ( first_visible_line.getPosition() + mouse_y - 1 > int(element_count) ) if ( first_visible_line.getPosition() + mouse_y - 1 > int(getCount()) )
return; return;
if ( itemlist.empty() ) if ( itemlist.empty() )
@ -1302,7 +1303,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
else else
item->expand(); item->expand();
adjustScrollbars (element_count); adjustScrollbars (getCount()); // after expand or collapse
if ( isShown() ) if ( isShown() )
draw(); draw();
@ -1408,7 +1409,7 @@ void FListView::onFocusOut (FFocusEvent*)
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
} }
delOwnTimer(); delOwnTimers();
} }
@ -1454,7 +1455,7 @@ void FListView::adjustViewport (const int element_count)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::adjustScrollbars (const std::size_t element_count) void FListView::adjustScrollbars (const std::size_t element_count) const
{ {
const std::size_t width = getClientWidth(); const std::size_t width = getClientWidth();
const std::size_t height = getClientHeight(); const std::size_t height = getClientHeight();
@ -1585,7 +1586,7 @@ void FListView::sort (Compare cmp)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FListView::getAlignOffset ( const fc::text_alignment align std::size_t FListView::getAlignOffset ( const fc::text_alignment align
, const std::size_t column_width , const std::size_t column_width
, const std::size_t width ) , const std::size_t width ) const
{ {
assert ( align == fc::alignLeft assert ( align == fc::alignLeft
|| align == fc::alignCenter || align == fc::alignCenter
@ -1681,7 +1682,7 @@ void FListView::drawBorder()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::drawScrollbars() void FListView::drawScrollbars() const
{ {
if ( ! hbar->isShown() && isHorizontallyScrollable() ) if ( ! hbar->isShown() && isHorizontallyScrollable() )
hbar->show(); hbar->show();
@ -1892,7 +1893,7 @@ void FListView::clearList()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListView::setLineAttributes ( bool is_current inline void FListView::setLineAttributes ( bool is_current
, bool is_focus ) , bool is_focus ) const
{ {
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setColor (wc->list_fg, wc->list_bg); setColor (wc->list_fg, wc->list_bg);
@ -1927,7 +1928,7 @@ inline void FListView::setLineAttributes ( bool is_current
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FListView::getCheckBox (const FListViewItem* item) inline FString FListView::getCheckBox (const FListViewItem* item) const
{ {
FString checkbox{""}; FString checkbox{""};
@ -1958,7 +1959,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FListView::getLinePrefix ( const FListViewItem* item inline FString FListView::getLinePrefix ( const FListViewItem* item
, std::size_t indent ) , std::size_t indent ) const
{ {
FString line{""}; FString line{""};
@ -2286,7 +2287,7 @@ void FListView::recalculateHorizontalBar (std::size_t len)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::recalculateVerticalBar (std::size_t element_count) void FListView::recalculateVerticalBar (std::size_t element_count) const
{ {
const std::size_t height = getClientHeight(); const std::size_t height = getClientHeight();
const int vmax = ( element_count > height ) const int vmax = ( element_count > height )
@ -2447,7 +2448,7 @@ void FListView::dragUp (int mouse_button)
if ( current_iter.getPosition() == 0 ) if ( current_iter.getPosition() == 0 )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
} }
} }
@ -2472,7 +2473,7 @@ void FListView::dragDown (int mouse_button)
if ( current_iter.getPosition() - 1 == int(getCount()) ) if ( current_iter.getPosition() - 1 == int(getCount()) )
{ {
delOwnTimer(); delOwnTimers();
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
} }
} }
@ -2480,7 +2481,7 @@ void FListView::dragDown (int mouse_button)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::stopDragScroll() void FListView::stopDragScroll()
{ {
delOwnTimer(); delOwnTimers();
scroll_timer = false; scroll_timer = false;
scroll_distance = 1; scroll_distance = 1;
drag_scroll = fc::noScroll; drag_scroll = fc::noScroll;
@ -2496,7 +2497,7 @@ FObject::iterator FListView::appendItem (FListViewItem* item)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::processClick() void FListView::processClick() const
{ {
if ( itemlist.empty() ) if ( itemlist.empty() )
return; return;
@ -2505,13 +2506,13 @@ void FListView::processClick()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::processChanged() void FListView::processChanged() const
{ {
emitCallback("row-changed"); emitCallback("row-changed");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::changeOnResize() void FListView::changeOnResize() const
{ {
if ( FTerm::isNewFont() ) if ( FTerm::isNewFont() )
{ {
@ -2855,7 +2856,7 @@ void FListView::scrollBy (int dx, int dy)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_vbarChange (const FWidget*, const FDataPtr) void FListView::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::sType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
@ -2922,7 +2923,7 @@ void FListView::cb_vbarChange (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_hbarChange (const FWidget*, const FDataPtr) void FListView::cb_hbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::sType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flog.cpp - Interface of the FINAL CUT logger * * flog.cpp - Interface of the FINAL CUT logger *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -45,7 +45,7 @@ FLog::~FLog() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FLog& FLog::operator << (LogLevel l) FLog& FLog::operator << (LogLevel l)
{ {
using namespace std::placeholders; using std::placeholders::_1;
sync(); sync();
switch ( l ) switch ( l )

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* flogger.cpp - The FINAL CUT text logger * * flogger.cpp - The FINAL CUT text logger *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <string>
#include "final/flogger.h" #include "final/flogger.h"
namespace finalcut namespace finalcut
@ -42,7 +44,7 @@ FLogger::~FLogger() // destructor
// private methods of FLogger // private methods of FLogger
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLogger::newlineReplace ( std::string& str void FLogger::newlineReplace ( std::string& str
, const std::string& replace_str ) , const std::string& replace_str ) const
{ {
std::size_t pos{0}; std::size_t pos{0};
std::size_t npos{std::string::npos}; std::size_t npos{std::string::npos};
@ -56,7 +58,7 @@ void FLogger::newlineReplace ( std::string& str
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const std::string FLogger::getTimeString() const std::string FLogger::getTimeString() const
{ {
char str[100]; char str[100];
const auto& now = std::chrono::system_clock::now(); const auto& now = std::chrono::system_clock::now();
@ -69,7 +71,7 @@ const std::string FLogger::getTimeString()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const std::string FLogger::getEOL() const std::string FLogger::getEOL() const
{ {
if ( getEnding() == FLog::LF ) if ( getEnding() == FLog::LF )
return "\n"; return "\n";

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmenu.cpp - Widget FMenu * * fmenu.cpp - Widget FMenu *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -47,7 +47,7 @@ namespace finalcut
FMenu::FMenu(FWidget* parent) FMenu::FMenu(FWidget* parent)
: FWindow{parent} : FWindow{parent}
{ {
init(parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -55,7 +55,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent)
: FWindow{parent} : FWindow{parent}
, menuitem{txt, parent} , menuitem{txt, parent}
{ {
init(parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -327,26 +327,21 @@ void FMenu::onMouseMove (FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitemEnabled (const FWidget*, const FDataPtr) void FMenu::cb_menuitemEnabled()
{ {
setEnable(); setEnable();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitemDisabled (const FWidget*, const FDataPtr) void FMenu::cb_menuitemDisabled()
{ {
setDisable(); setDisable();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::cb_menuitemToggled (FWidget* widget, const FDataPtr) void FMenu::cb_menuitemToggled (const FMenuItem* m_item) const
{ {
const auto& m_item = static_cast<FMenuItem*>(widget); if ( ! (has_checkable_items && m_item && m_item->isChecked()) )
if ( ! has_checkable_items )
return;
if ( ! m_item->isChecked() )
return; return;
auto list = getItemList(); auto list = getItemList();
@ -444,7 +439,7 @@ bool FMenu::isMouseOverSuperMenu (const FPoint& termpos)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::isMouseOverMenuBar (const FPoint& termpos) bool FMenu::isMouseOverMenuBar (const FPoint& termpos) const
{ {
if ( getMenuBar() if ( getMenuBar()
&& isMenuBar(getMenuBar()) && isMenuBar(getMenuBar())
@ -457,7 +452,7 @@ bool FMenu::isMouseOverMenuBar (const FPoint& termpos)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::init(FWidget* parent) void FMenu::init()
{ {
setTopPadding(1); setTopPadding(1);
setLeftPadding(1); setLeftPadding(1);
@ -469,6 +464,7 @@ void FMenu::init(FWidget* parent)
hide(); hide();
resetColors(); resetColors();
menuitem.setMenu(this); menuitem.setMenu(this);
FWidget* parent = getParentWidget();
if ( parent ) if ( parent )
{ {
@ -496,13 +492,13 @@ void FMenu::initCallbacks()
menuitem.addCallback menuitem.addCallback
( (
"enable", "enable",
F_METHOD_CALLBACK (this, &FMenu::cb_menuitemEnabled) this, &FMenu::cb_menuitemEnabled
); );
menuitem.addCallback menuitem.addCallback
( (
"disable", "disable",
F_METHOD_CALLBACK (this, &FMenu::cb_menuitemEnabled) this, &FMenu::cb_menuitemDisabled
); );
} }
@ -562,7 +558,7 @@ void FMenu::calculateDimensions()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::adjustItems() void FMenu::adjustItems() const
{ {
for (auto&& item : getItemList()) for (auto&& item : getItemList())
{ {
@ -584,7 +580,7 @@ void FMenu::adjustItems()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FMenu::adjustX (int x_pos) int FMenu::adjustX (int x_pos) const
{ {
// Is menu outside on the right of the screen? // Is menu outside on the right of the screen?
if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) ) if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) )
@ -656,7 +652,7 @@ void FMenu::hideSubMenus()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::hideSuperMenus() void FMenu::hideSuperMenus() const
{ {
// hide all menus to the top // hide all menus to the top
auto super = getSuperMenu(); auto super = getSuperMenu();
@ -911,7 +907,7 @@ void FMenu::mouseUpOverBorder()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::mouseMoveOverBorder (mouseStates& ms) void FMenu::mouseMoveOverBorder (mouseStates& ms) const
{ {
// Mouse is moved over border or separator line // Mouse is moved over border or separator line
@ -979,7 +975,7 @@ void FMenu::passEventToSuperMenu (FMouseEvent* const& ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::passEventToMenuBar (FMouseEvent* const& ev) void FMenu::passEventToMenuBar (FMouseEvent* const& ev) const
{ {
// Mouse event handover to the menu bar // Mouse event handover to the menu bar
@ -1144,7 +1140,7 @@ bool FMenu::selectPrevItem()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::keypressMenuBar (FKeyEvent* ev) void FMenu::keypressMenuBar (FKeyEvent* ev) const
{ {
auto mbar = getMenuBar(); auto mbar = getMenuBar();
@ -1428,15 +1424,16 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
const FString accel_name {FTerm::getKeyName(accel_key)}; const FString accel_name {FTerm::getKeyName(accel_key)};
const std::size_t c = ( has_checkable_items ) ? 1 : 0; const std::size_t c = ( has_checkable_items ) ? 1 : 0;
const std::size_t accel_len = accel_name.getLength(); const std::size_t accel_len = accel_name.getLength();
const std::size_t len = max_item_width - (startpos + accel_len + c + 2); const std::size_t plain_text_length = startpos + accel_len + c + 2;
if ( len > 0 ) if ( plain_text_length >= max_item_width )
{ return;
// Print filling blank spaces + accelerator key name
const FString spaces {len, L' '}; // Print filling blank spaces + accelerator key name
print (spaces + accel_name); const std::size_t len = max_item_width - plain_text_length;
startpos = max_item_width - (c + 2); const FString spaces {len, L' '};
} print (spaces + accel_name);
startpos = max_item_width - (c + 2);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1489,7 +1486,7 @@ inline void FMenu::setLineAttributes (const FMenuItem* m_item, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenu::setCursorToHotkeyPosition (FMenuItem* m_item) inline void FMenu::setCursorToHotkeyPosition (FMenuItem* m_item) const
{ {
const bool is_checkable = m_item->checkable; const bool is_checkable = m_item->checkable;
const bool is_selected = m_item->isSelected(); const bool is_selected = m_item->isSelected();
@ -1615,7 +1612,7 @@ inline void FMenu::closeMenu()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::processActivate() void FMenu::processActivate() const
{ {
emitCallback("activate"); emitCallback("activate");
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmenubar.cpp - Widget FMenuBar * * fmenubar.cpp - Widget FMenuBar *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -228,16 +228,14 @@ void FMenuBar::onAccel (FAccelEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::cb_itemDeactivated (FWidget* widget, const FDataPtr) void FMenuBar::cb_itemDeactivated (const FMenuItem* menuitem) const
{ {
auto menuitem = static_cast<FMenuItem*>(widget); if ( ! menuitem->hasMenu() )
return;
if ( menuitem->hasMenu() ) auto menu = menuitem->getMenu();
{ menu->hide();
auto menu = menuitem->getMenu(); menu->hideSubMenus();
menu->hide();
menu->hideSubMenus();
}
} }
@ -263,7 +261,7 @@ void FMenuBar::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::calculateDimensions() void FMenuBar::calculateDimensions() const
{ {
FPoint item_pos{1, 1}; FPoint item_pos{1, 1};
@ -400,7 +398,7 @@ bool FMenuBar::selectPrevItem()
setSelectedItem(prev); setSelectedItem(prev);
redraw(); redraw();
setTerminalUpdates (FVTerm::stop_terminal_updates); setTerminalUpdates (FVTerm::start_terminal_updates);
break; break;
} }
} }
@ -577,7 +575,7 @@ inline void FMenuBar::setLineAttributes (const FMenuItem* menuitem)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenuBar::setCursorToHotkeyPosition ( FMenuItem* menuitem inline void FMenuBar::setCursorToHotkeyPosition ( FMenuItem* menuitem
, std::size_t hotkeypos ) , std::size_t hotkeypos ) const
{ {
if ( ! menuitem->isSelected() ) if ( ! menuitem->isSelected() )
return; return;
@ -675,7 +673,7 @@ inline void FMenuBar::drawTrailingSpace (std::size_t& x)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::adjustItems() void FMenuBar::adjustItems() const
{ {
int item_X = 1; int item_X = 1;
int item_Y = 1; int item_Y = 1;
@ -928,7 +926,7 @@ void FMenuBar::mouseMoveOverList (const FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::passEventToMenu (const FMouseEvent* const& ev) void FMenuBar::passEventToMenu (const FMouseEvent* const& ev) const
{ {
if ( ! hasSelectedItem() || ! getSelectedItem()->hasMenu() ) if ( ! hasSelectedItem() || ! getSelectedItem()->hasMenu() )
return; return;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmenuitem.cpp - Widget FMenuItem * * fmenuitem.cpp - Widget FMenuItem *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <memory> #include <memory>
#include <utility>
#include "final/fapplication.h" #include "final/fapplication.h"
#include "final/fdialog.h" #include "final/fdialog.h"
@ -44,7 +45,7 @@ namespace finalcut
FMenuItem::FMenuItem (FWidget* parent) FMenuItem::FMenuItem (FWidget* parent)
: FWidget{parent} : FWidget{parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -52,7 +53,7 @@ FMenuItem::FMenuItem (const FString& txt, FWidget* parent)
: FWidget{parent} : FWidget{parent}
, text{txt} , text{txt}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -61,7 +62,7 @@ FMenuItem::FMenuItem (FKey k, const FString& txt, FWidget* parent)
, text{txt} , text{txt}
, accel_key{k} , accel_key{k}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -224,7 +225,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::openMenu() void FMenuItem::openMenu() const
{ {
if ( ! hasMenu() ) if ( ! hasMenu() )
return; return;
@ -401,7 +402,7 @@ void FMenuItem::onAccel (FAccelEvent* ev)
setSelected(); setSelected();
mbar->setSelectedItem(this); mbar->setSelectedItem(this);
openMenu(); openMenu();
auto focused_widget = static_cast<FWidget*>(ev->focusedWidget()); auto focused_widget = ev->focusedWidget();
menu->unselectItem(); menu->unselectItem();
menu->selectFirstItem(); menu->selectFirstItem();
@ -503,7 +504,7 @@ FMenuList* FMenuItem::getFMenuList (FWidget& widget)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::init (FWidget* parent) void FMenuItem::init()
{ {
text_length = text.getLength(); text_length = text.getLength();
text_width = getColumnWidth(text); text_width = getColumnWidth(text);
@ -519,6 +520,7 @@ void FMenuItem::init (FWidget* parent)
} }
setGeometry (FPoint{1, 1}, FSize{text_width + 2, 1}, false); setGeometry (FPoint{1, 1}, FSize{text_width + 2, 1}, false);
FWidget* parent = getParentWidget();
if ( ! parent ) if ( ! parent )
return; return;
@ -545,7 +547,8 @@ void FMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"deactivate", "deactivate",
F_METHOD_CALLBACK (menubar_ptr, &FMenuBar::cb_itemDeactivated) std::move(menubar_ptr), &FMenuBar::cb_itemDeactivated,
this
); );
} }
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
@ -566,31 +569,31 @@ void FMenuItem::updateSuperMenuDimensions()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processEnable() void FMenuItem::processEnable() const
{ {
emitCallback("enable"); emitCallback("enable");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processDisable() void FMenuItem::processDisable() const
{ {
emitCallback("disable"); emitCallback("disable");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processActivate() void FMenuItem::processActivate() const
{ {
emitCallback("activate"); emitCallback("activate");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processDeactivate() void FMenuItem::processDeactivate() const
{ {
emitCallback("deactivate"); emitCallback("deactivate");
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::createDialogList (FMenu* winmenu) void FMenuItem::createDialogList (FMenu* winmenu) const
{ {
winmenu->clear(); winmenu->clear();
@ -627,14 +630,17 @@ void FMenuItem::createDialogList (FMenu* winmenu)
win_item->addCallback win_item->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_switchToDialog), static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
static_cast<FDataPtr>(win) &FMenuItem::cb_switchToDialog,
win
); );
win->addCallback win->addCallback
( (
"destroy", "destroy",
F_METHOD_CALLBACK (win_item, &FMenuItem::cb_destroyDialog) static_cast<std::remove_reference<decltype(win_item)>::type>(win_item),
&FMenuItem::cb_destroyDialog,
win
); );
win_item->associated_window = win; win_item->associated_window = win;
@ -650,7 +656,7 @@ void FMenuItem::createDialogList (FMenu* winmenu)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename T> template <typename T>
void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev
, fc::events ev_type ) , fc::events ev_type ) const
{ {
if ( ! widget ) if ( ! widget )
return; return;
@ -694,28 +700,25 @@ void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::cb_switchToDialog (const FWidget*, FDataPtr data) void FMenuItem::cb_switchToDialog (FDialog* win) const
{ {
auto win = static_cast<FDialog*>(data); if ( ! win )
return;
if ( win ) auto focus = getFocusWidget();
{ FAccelEvent a_ev (fc::Accelerator_Event, focus);
auto focus = getFocusWidget(); FApplication::sendEvent (win, &a_ev);
FAccelEvent a_ev (fc::Accelerator_Event, focus);
FApplication::sendEvent (win, &a_ev);
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::cb_destroyDialog (FWidget* widget, const FDataPtr) void FMenuItem::cb_destroyDialog (FDialog* win)
{ {
auto win = static_cast<FDialog*>(widget);
const auto& fapp = FApplication::getApplicationObject(); const auto& fapp = FApplication::getApplicationObject();
if ( win && fapp ) if ( win && fapp )
{ {
delAccelerator(win); delAccelerator(win);
delCallback(win); delCallback(std::move(win));
associated_window = nullptr; associated_window = nullptr;
} }
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmenulist.cpp - Menu item container base class * * fmenulist.cpp - Menu item container base class *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmessagebox.cpp - Widget FMessageBox (a text message window) * * fmessagebox.cpp - Widget FMessageBox (a text message window) *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -51,9 +51,10 @@ static const char* const button_text[] =
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMessageBox::FMessageBox (FWidget* parent) FMessageBox::FMessageBox (FWidget* parent)
: FDialog{parent} : FDialog{parent}
, button_digit{FMessageBox::Ok, 0, 0}
{ {
setTitlebarText("Message for you"); setTitlebarText("Message for you");
init(FMessageBox::Ok, 0, 0); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -64,14 +65,15 @@ FMessageBox::FMessageBox (const FMessageBox& mbox)
, text_components{mbox.text_components} , text_components{mbox.text_components}
, max_line_width{mbox.max_line_width} , max_line_width{mbox.max_line_width}
, emphasis_color{mbox.emphasis_color} , emphasis_color{mbox.emphasis_color}
, button_digit{mbox.button_digit[0],
mbox.button_digit[1],
mbox.button_digit[2]}
, num_buttons{mbox.num_buttons} , num_buttons{mbox.num_buttons}
, text_num_lines{mbox.text_num_lines} , text_num_lines{mbox.text_num_lines}
, center_text{mbox.center_text} , center_text{mbox.center_text}
{ {
setTitlebarText (mbox.getTitlebarText()); setTitlebarText (mbox.getTitlebarText());
init ( mbox.button_digit[0] init();
, mbox.button_digit[1]
, mbox.button_digit[2] );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -83,9 +85,10 @@ FMessageBox::FMessageBox ( const FString& caption
, FWidget* parent ) , FWidget* parent )
: FDialog{parent} : FDialog{parent}
, text{message} , text{message}
, button_digit{button0, button1, button2}
{ {
setTitlebarText(caption); setTitlebarText(caption);
init(button0, button1, button2); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -105,12 +108,14 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
} }
else else
{ {
for (uInt n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
delete button[n]; if ( button[n] )
delete button[n];
if ( mbox.getParentWidget() ) if ( mbox.getParentWidget() )
mbox.getParentWidget()->addChild (this); mbox.getParentWidget()->addChild (this);
setTitlebarText (mbox.getTitlebarText());
headline_text = mbox.headline_text; headline_text = mbox.headline_text;
text = mbox.text; text = mbox.text;
text_components = mbox.text_components; text_components = mbox.text_components;
@ -119,11 +124,10 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
emphasis_color = mbox.emphasis_color; emphasis_color = mbox.emphasis_color;
num_buttons = mbox.num_buttons; num_buttons = mbox.num_buttons;
text_num_lines = mbox.text_num_lines; text_num_lines = mbox.text_num_lines;
button_digit[0] = mbox.button_digit[0];
setTitlebarText (mbox.getTitlebarText()); button_digit[1] = mbox.button_digit[1];
init ( mbox.button_digit[0] button_digit[2] = mbox.button_digit[2];
, mbox.button_digit[1] init();
, mbox.button_digit[2] );
return *this; return *this;
} }
@ -135,8 +139,9 @@ void FMessageBox::setHeadline (const FString& headline)
headline_text.setString(headline); headline_text.setString(headline);
setHeight(getHeight() + 2, true); setHeight(getHeight() + 2, true);
for (uInt n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
button[n]->setY (int(getHeight()) - 4, false); if ( button[n] )
button[n]->setY (int(getHeight()) - 4, false);
const std::size_t column_width = getColumnWidth(headline_text); const std::size_t column_width = getColumnWidth(headline_text);
@ -149,12 +154,14 @@ void FMessageBox::setText (const FString& txt)
{ {
text.setString(txt); text.setString(txt);
calculateDimensions(); calculateDimensions();
button[0]->setY (int(getHeight()) - 4, false);
if ( button_digit[1] != 0 ) if ( button[0] )
button[0]->setY (int(getHeight()) - 4, false);
if ( button[1] && button_digit[1] != 0 )
button[1]->setY (int(getHeight()) - 4, false); button[1]->setY (int(getHeight()) - 4, false);
if ( button_digit[2] != 0 ) if ( button[2] && button_digit[2] != 0 )
button[2]->setY (int(getHeight()) - 4, false); button[2]->setY (int(getHeight()) - 4, false);
adjustButtons(); adjustButtons();
@ -188,39 +195,35 @@ void FMessageBox::adjustSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::cb_processClick (const FWidget*, FDataPtr data) void FMessageBox::cb_processClick (int reply)
{ {
const int reply = *(static_cast<int*>(data)); done(reply);
done (reply);
} }
// private methods of FMessageBox // private methods of FMessageBox
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::init (int button0, int button1, int button2) void FMessageBox::init()
{ {
calculateDimensions(); calculateDimensions();
if ( (button2 && ! button1) || (button1 && ! button0) ) if ( (button_digit[2] && ! button_digit[1])
|| (button_digit[1] && ! button_digit[0]) )
{ {
button0 = button1 = button2 = 0; button_digit[0] = button_digit[1] = button_digit[2] = 0;
} }
if ( button0 == 0 ) if ( button_digit[0] == 0 )
button0 = FMessageBox::Ok; button_digit[0] = FMessageBox::Ok;
if ( button1 == 0 && button2 == 0 ) if ( button_digit[1] == 0 && button_digit[2] == 0 )
num_buttons = 1; num_buttons = 1;
else if ( button2 == 0 ) else if ( button_digit[2] == 0 )
num_buttons = 2; num_buttons = 2;
else else
num_buttons = 3; num_buttons = 3;
button_digit[0] = button0; allocation();
button_digit[1] = button1;
button_digit[2] = button2;
allocation (button0, button1, button2);
resizeButtons(); resizeButtons();
adjustButtons(); adjustButtons();
initCallbacks(); initCallbacks();
@ -228,30 +231,30 @@ void FMessageBox::init (int button0, int button1, int button2)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMessageBox::allocation (int button0, int button1, int button2) inline void FMessageBox::allocation()
{ {
try try
{ {
button[0] = new FButton (this); button[0] = new FButton (this);
button[0]->setText(button_text[button0]); button[0]->setText(button_text[button_digit[0]]);
button[0]->setPos(FPoint{3, int(getHeight()) - 4}, false); button[0]->setPos(FPoint{3, int(getHeight()) - 4}, false);
button[0]->setWidth(1, false); button[0]->setWidth(1, false);
button[0]->setHeight(1, false); button[0]->setHeight(1, false);
button[0]->setFocus(); button[0]->setFocus();
if ( button1 > 0 ) if ( button_digit[1] > 0 )
{ {
button[1] = new FButton(this); button[1] = new FButton(this);
button[1]->setText(button_text[button1]); button[1]->setText(button_text[button_digit[1]]);
button[1]->setPos(FPoint{17, int(getHeight()) - 4}, false); button[1]->setPos(FPoint{17, int(getHeight()) - 4}, false);
button[1]->setWidth(0, false); button[1]->setWidth(0, false);
button[1]->setHeight(1, false); button[1]->setHeight(1, false);
} }
if ( button2 > 0 ) if ( button_digit[2] > 0 )
{ {
button[2] = new FButton(this); button[2] = new FButton(this);
button[2]->setText(button_text[button2]); button[2]->setText(button_text[button_digit[2]]);
button[2]->setPos(FPoint{32, int(getHeight()) - 4}, false); button[2]->setPos(FPoint{32, int(getHeight()) - 4}, false);
button[2]->setWidth(0, false); button[2]->setWidth(0, false);
button[2]->setHeight(1, false); button[2]->setHeight(1, false);
@ -267,40 +270,41 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMessageBox::deallocation() inline void FMessageBox::deallocation()
{ {
for (uInt n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
delete button[n]; if ( button[n] )
delete button[n];
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMessageBox::initCallbacks() inline void FMessageBox::initCallbacks()
{ {
if ( button_digit[0] != 0 ) if ( button[0] && button_digit[0] != 0 )
{ {
button[0]->addCallback button[0]->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), this, &FMessageBox::cb_processClick,
static_cast<FDataPtr>(&button_digit[0]) button_digit[0]
); );
} }
if ( button_digit[1] != 0 ) if ( button[1] && button_digit[1] != 0 )
{ {
button[1]->addCallback button[1]->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), this, &FMessageBox::cb_processClick,
static_cast<FDataPtr>(&button_digit[1]) button_digit[1]
); );
} }
if ( button_digit[2] != 0 ) if ( button[2] && button_digit[2] != 0 )
{ {
button[2]->addCallback button[2]->addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &FMessageBox::cb_processClick), this, &FMessageBox::cb_processClick,
static_cast<FDataPtr>(&button_digit[2]) button_digit[2]
); );
} }
} }
@ -382,13 +386,16 @@ void FMessageBox::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::resizeButtons() void FMessageBox::resizeButtons() const
{ {
std::size_t len[3]{}; std::size_t len[3]{};
std::size_t max_size{}; std::size_t max_size{};
for (std::size_t n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
{ {
if ( ! button[n] )
continue;
len[n] = button[n]->getText().getLength(); len[n] = button[n]->getText().getLength();
if ( button[n]->getText().includes('&') ) if ( button[n]->getText().includes('&') )
@ -409,8 +416,9 @@ void FMessageBox::resizeButtons()
if ( max_size < 7 ) if ( max_size < 7 )
max_size = 7; max_size = 7;
for (std::size_t n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
button[n]->setWidth(max_size + 3, false); if ( button[n] )
button[n]->setWidth(max_size + 3, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -419,8 +427,11 @@ void FMessageBox::adjustButtons()
static constexpr std::size_t gap = 4; static constexpr std::size_t gap = 4;
std::size_t btn_width{0}; std::size_t btn_width{0};
for (std::size_t n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
{ {
if ( ! button[n] )
continue;
if ( n == num_buttons - 1 ) if ( n == num_buttons - 1 )
btn_width += button[n]->getWidth(); btn_width += button[n]->getWidth();
else else
@ -438,8 +449,11 @@ void FMessageBox::adjustButtons()
const int btn_x = int((getWidth() - btn_width) / 2); const int btn_x = int((getWidth() - btn_width) / 2);
for (std::size_t n{0}; n < num_buttons; n++) for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
{ {
if ( ! button[n] )
continue;
if ( n == 0 ) if ( n == 0 )
button[n]->setX(btn_x); button[n]->setX(btn_x);
else else

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fmouse.cpp - Read mouse events * * fmouse.cpp - Read mouse events *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,12 +20,13 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <new> #include <new>
#include <stdio.h>
#include <unistd.h>
#include "final/fconfig.h" #include "final/fconfig.h"
#include "final/fkeyboard.h" #include "final/fkeyboard.h"
@ -59,7 +60,7 @@ const FString FMouse::getClassName() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint& FMouse::getPos() inline const FPoint& FMouse::getPos() const
{ {
return mouse; return mouse;
} }
@ -89,7 +90,7 @@ inline void FMouse::setDblclickInterval (const uInt64 timeout)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMouse::hasEvent() inline bool FMouse::hasEvent() const
{ {
return mouse_event_occurred; return mouse_event_occurred;
} }
@ -172,45 +173,11 @@ inline bool FMouse::isMoved()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMouse::isInputDataPending() inline bool FMouse::isInputDataPending() const
{ {
return input_data_pending; return input_data_pending;
} }
//----------------------------------------------------------------------
inline FMouse* FMouse::createMouseObject (const mouse_type mt)
{
assert ( mt == FMouse::none
|| mt == FMouse::gpm
|| mt == FMouse::x11
|| mt == FMouse::sgr
|| mt == FMouse::urxvt );
switch ( mt )
{
case none:
return nullptr;
case gpm:
#ifdef F_HAVE_LIBGPM
return new FMouseGPM;
#else
return nullptr;
#endif
case x11:
return new FMouseX11;
case sgr:
return new FMouseSGR;
case urxvt:
return new FMouseUrxvt;
}
return nullptr;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::clearButtonState() void FMouse::clearButtonState()
{ {
@ -227,25 +194,25 @@ inline FMouse::FMouseButton& FMouse::getButtonState()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint& FMouse::getNewPos() inline const FPoint& FMouse::getNewPos() const
{ {
return new_mouse_position; return new_mouse_position;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt16 FMouse::getMaxWidth() uInt16 FMouse::getMaxWidth() const
{ {
return max_width; return max_width;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt16 FMouse::getMaxHeight() uInt16 FMouse::getMaxHeight() const
{ {
return max_height; return max_height;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt64 FMouse::getDblclickInterval() uInt64 FMouse::getDblclickInterval() const
{ {
return dblclick_interval; return dblclick_interval;
} }
@ -294,7 +261,7 @@ void FMouse::setEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouse::isDblclickTimeout (const timeval* time) bool FMouse::isDblclickTimeout (const timeval* time) const
{ {
return FObject::isTimeout (time, dblclick_interval); return FObject::isTimeout (time, dblclick_interval);
} }
@ -349,10 +316,10 @@ void FMouseGPM::processEvent (struct timeval*)
if ( Gpm_GetEvent(&gpm_ev) == 1 ) if ( Gpm_GetEvent(&gpm_ev) == 1 )
{ {
Gpm_FitEvent (&gpm_ev); Gpm_FitEvent (&gpm_ev);
GPM_DRAWPOINTER(&gpm_ev);
if ( ! hasSignificantEvents() ) if ( ! hasSignificantEvents() )
{ {
GPM_DRAWPOINTER(&gpm_ev);
has_gpm_mouse_data = false; has_gpm_mouse_data = false;
clearEvent(); clearEvent();
return; return;
@ -376,7 +343,6 @@ void FMouseGPM::processEvent (struct timeval*)
case GPM_UP: case GPM_UP:
interpretKeyUp(); interpretKeyUp();
default: default:
break; break;
} }
@ -389,7 +355,6 @@ void FMouseGPM::processEvent (struct timeval*)
else else
setPending(false); setPending(false);
GPM_DRAWPOINTER(&gpm_ev);
has_gpm_mouse_data = false; has_gpm_mouse_data = false;
setEvent(); setEvent();
return; return;
@ -412,9 +377,9 @@ bool FMouseGPM::gpmMouse (bool enable)
if ( enable ) if ( enable )
{ {
Gpm_Connect conn; Gpm_Connect conn;
conn.eventMask = uInt16(~0); // Get all including wheel event conn.eventMask = GPM_MOVE | GPM_DRAG | GPM_DOWN | GPM_UP;
conn.defaultMask = GPM_MOVE; conn.defaultMask = 0;
conn.maxMod = uInt16(~0); conn.maxMod = 0;
conn.minMod = 0; conn.minMod = 0;
Gpm_Open(&conn, 0); Gpm_Open(&conn, 0);
@ -431,7 +396,7 @@ bool FMouseGPM::gpmMouse (bool enable)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseGPM::hasSignificantEvents() bool FMouseGPM::hasSignificantEvents() const
{ {
return ! (gpm_ev.type & GPM_MOVE) return ! (gpm_ev.type & GPM_MOVE)
|| gpm_ev.wdy != 0 || gpm_ev.wdy != 0
@ -510,14 +475,14 @@ bool FMouseGPM::getGpmKeyPressed (bool is_pending)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseGPM::drawGpmPointer() void FMouseGPM::drawGpmPointer() const
{ {
if ( isGpmMouseEnabled() && gpm_ev.x != -1 ) if ( isGpmMouseEnabled() && gpm_ev.x != -1 )
GPM_DRAWPOINTER(&gpm_ev); GPM_DRAWPOINTER(&gpm_ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FMouseGPM::gpmEvent (bool clear) int FMouseGPM::gpmEvent (bool clear) const
{ {
const int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no; const int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no;
fd_set ifds{}; fd_set ifds{};
@ -877,7 +842,8 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseSGR::setPressedButtonState (const int btn, const struct timeval* time) void FMouseSGR::setPressedButtonState ( const int btn
, const struct timeval* time )
{ {
// Gets the extended x11 mouse mode (SGR) status for pressed buttons // Gets the extended x11 mouse mode (SGR) status for pressed buttons
@ -1216,12 +1182,12 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
FMouseControl::FMouseControl() FMouseControl::FMouseControl()
{ {
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
mouse_protocol[FMouse::gpm] = FMouse::createMouseObject(FMouse::gpm); mouse_protocol[FMouse::gpm] = FMouse::createMouseObject<FMouseGPM>();
#endif #endif
mouse_protocol[FMouse::x11] = FMouse::createMouseObject(FMouse::x11); mouse_protocol[FMouse::x11] = FMouse::createMouseObject<FMouseX11>();
mouse_protocol[FMouse::sgr] = FMouse::createMouseObject(FMouse::sgr); mouse_protocol[FMouse::sgr] = FMouse::createMouseObject<FMouseSGR>();
mouse_protocol[FMouse::urxvt] = FMouse::createMouseObject(FMouse::urxvt); mouse_protocol[FMouse::urxvt] = FMouse::createMouseObject<FMouseUrxvt>();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1632,7 +1598,7 @@ FMouse* FMouseControl::getMouseWithEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::xtermMouse (bool enable) void FMouseControl::xtermMouse (bool enable) const
{ {
// activate/deactivate the xterm mouse support // activate/deactivate the xterm mouse support

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fobject.cpp - Object container base class of all widget objects * * fobject.cpp - Object container base class of all widget objects *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -72,7 +72,7 @@ FObject::FObject (FObject* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::~FObject() // destructor FObject::~FObject() // destructor
{ {
delOwnTimer(); // Delete all timers of this object delOwnTimers(); // Delete all timers of this object
if ( ! has_parent && timer_list ) if ( ! has_parent && timer_list )
{ {
@ -307,7 +307,7 @@ int FObject::addTimer (int interval)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::delTimer (int id) bool FObject::delTimer (int id) const
{ {
// Deletes a timer by using the timer identifier number // Deletes a timer by using the timer identifier number
@ -333,7 +333,7 @@ bool FObject::delTimer (int id)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::delOwnTimer() bool FObject::delOwnTimers() const
{ {
// Deletes all timers of this object // Deletes all timers of this object
@ -359,7 +359,7 @@ bool FObject::delOwnTimer()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::delAllTimer() bool FObject::delAllTimers() const
{ {
// Deletes all timers of all objects // Deletes all timers of all objects

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* foptiattr.cpp - Sets video attributes in optimized order * * foptiattr.cpp - Sets video attributes in optimized order *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2016-2020 Markus Gans * * Copyright 2016-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -1239,7 +1239,7 @@ inline bool FOptiAttr::hasColorChanged ( const FChar* const& term
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::resetColor (FChar*& attr) inline void FOptiAttr::resetColor (FChar*& attr) const
{ {
if ( attr ) if ( attr )
{ {
@ -1501,13 +1501,13 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term
if ( term->fg_color != fg || frev ) if ( term->fg_color != fg || frev )
{ {
color_str = FTermcap::encodeParameter(AF, ansi_fg); color_str = FTermcap::encodeParameter(AF, ansi_fg, 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str);
} }
if ( term->bg_color != bg || frev ) if ( term->bg_color != bg || frev )
{ {
color_str = FTermcap::encodeParameter(AB, ansi_bg); color_str = FTermcap::encodeParameter(AB, ansi_bg, 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str);
} }
} }
@ -1515,13 +1515,13 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term
{ {
if ( term->fg_color != fg || frev ) if ( term->fg_color != fg || frev )
{ {
color_str = FTermcap::encodeParameter(Sf, fg); color_str = FTermcap::encodeParameter(Sf, fg, 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str);
} }
if ( term->bg_color != bg || frev ) if ( term->bg_color != bg || frev )
{ {
color_str = FTermcap::encodeParameter(Sb, bg); color_str = FTermcap::encodeParameter(Sb, bg, 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str);
} }
} }
@ -1529,13 +1529,13 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term
{ {
fg = vga2ansi(fg); fg = vga2ansi(fg);
bg = vga2ansi(bg); bg = vga2ansi(bg);
color_str = FTermcap::encodeParameter(sp, fg, bg); color_str = FTermcap::encodeParameter(sp, fg, bg, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str);
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::resetAttribute (FChar*& attr) inline void FOptiAttr::resetAttribute (FChar*& attr) const
{ {
if ( attr ) if ( attr )
{ {
@ -1545,7 +1545,7 @@ inline void FOptiAttr::resetAttribute (FChar*& attr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiAttr::reset (FChar*& attr) inline void FOptiAttr::reset (FChar*& attr) const
{ {
if ( attr ) if ( attr )
{ {
@ -1555,7 +1555,7 @@ inline void FOptiAttr::reset (FChar*& attr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FOptiAttr::caused_reset_attributes (const char cap[], uChar test) bool FOptiAttr::caused_reset_attributes (const char cap[], uChar test) const
{ {
// test if "cap" reset all attributes // test if "cap" reset all attributes
@ -1648,14 +1648,14 @@ inline void FOptiAttr::detectSwitchOff (const FChar* const& term, const FChar* c
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiAttr::switchOn() inline bool FOptiAttr::switchOn() const
{ {
auto on_ptr = &on; auto on_ptr = &on;
return hasAttribute(on_ptr); return hasAttribute(on_ptr);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiAttr::switchOff() inline bool FOptiAttr::switchOff() const
{ {
auto off_ptr = &off; auto off_ptr = &off;
return hasAttribute(off_ptr); return hasAttribute(off_ptr);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* foptimove.cpp - Cursor movement optimization * * foptimove.cpp - Cursor movement optimization *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -268,7 +268,7 @@ void FOptiMove::set_cursor_right (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_cursor_address (const char cap[]) void FOptiMove::set_cursor_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23); const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23);
F_cursor_address.cap = cap; F_cursor_address.cap = cap;
@ -286,9 +286,9 @@ void FOptiMove::set_cursor_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_column_address (const char cap[]) void FOptiMove::set_column_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_column_address.cap = cap; F_column_address.cap = cap;
F_column_address.duration = capDuration (temp, 1); F_column_address.duration = capDuration (temp, 1);
F_column_address.length = capDurationToLength (F_column_address.duration); F_column_address.length = capDurationToLength (F_column_address.duration);
@ -304,9 +304,9 @@ void FOptiMove::set_column_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_row_address (const char cap[]) void FOptiMove::set_row_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_row_address.cap = cap; F_row_address.cap = cap;
F_row_address.duration = capDuration (temp, 1); F_row_address.duration = capDuration (temp, 1);
F_row_address.length = capDurationToLength (F_row_address.duration); F_row_address.length = capDurationToLength (F_row_address.duration);
@ -322,9 +322,9 @@ void FOptiMove::set_row_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_up_cursor (const char cap[]) void FOptiMove::set_parm_up_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_parm_up_cursor.cap = cap; F_parm_up_cursor.cap = cap;
F_parm_up_cursor.duration = capDuration (temp, 1); F_parm_up_cursor.duration = capDuration (temp, 1);
F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration); F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration);
@ -340,9 +340,9 @@ void FOptiMove::set_parm_up_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_down_cursor (const char cap[]) void FOptiMove::set_parm_down_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_parm_down_cursor.cap = cap; F_parm_down_cursor.cap = cap;
F_parm_down_cursor.duration = capDuration (temp, 1); F_parm_down_cursor.duration = capDuration (temp, 1);
F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration); F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration);
@ -358,9 +358,9 @@ void FOptiMove::set_parm_down_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_left_cursor (const char cap[]) void FOptiMove::set_parm_left_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_parm_left_cursor.cap = cap; F_parm_left_cursor.cap = cap;
F_parm_left_cursor.duration = capDuration (temp, 1); F_parm_left_cursor.duration = capDuration (temp, 1);
F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration); F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration);
@ -376,9 +376,9 @@ void FOptiMove::set_parm_left_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_right_cursor (const char cap[]) void FOptiMove::set_parm_right_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_parm_right_cursor.cap = cap; F_parm_right_cursor.cap = cap;
F_parm_right_cursor.duration = capDuration (temp, 1); F_parm_right_cursor.duration = capDuration (temp, 1);
F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration); F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration);
@ -394,9 +394,9 @@ void FOptiMove::set_parm_right_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_erase_chars (const char cap[]) void FOptiMove::set_erase_chars (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_erase_chars.cap = cap; F_erase_chars.cap = cap;
F_erase_chars.duration = capDuration (temp, 1); F_erase_chars.duration = capDuration (temp, 1);
F_erase_chars.length = capDurationToLength (F_erase_chars.duration); F_erase_chars.length = capDurationToLength (F_erase_chars.duration);
@ -412,9 +412,9 @@ void FOptiMove::set_erase_chars (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_repeat_char (const char cap[]) void FOptiMove::set_repeat_char (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, ' ', 23); const char* temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0);
F_repeat_char.cap = cap; F_repeat_char.cap = cap;
F_repeat_char.duration = capDuration (temp, 1); F_repeat_char.duration = capDuration (temp, 1);
F_repeat_char.length = capDurationToLength (F_repeat_char.duration); F_repeat_char.length = capDurationToLength (F_repeat_char.duration);
@ -463,7 +463,7 @@ void FOptiMove::set_clr_eol (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::check_boundaries ( int& xold, int& yold void FOptiMove::check_boundaries ( int& xold, int& yold
, int& xnew, int& ynew ) , int& xnew, int& ynew ) const
{ {
if ( xold < 0 || xold >= int(screen_width) ) if ( xold < 0 || xold >= int(screen_width) )
xold = -1; xold = -1;
@ -549,7 +549,7 @@ void FOptiMove::calculateCharDuration()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::capDuration (const char cap[], int affcnt) int FOptiMove::capDuration (const char cap[], int affcnt) const
{ {
// calculate the duration in milliseconds of a given operation // calculate the duration in milliseconds of a given operation
// cap - the term capability // cap - the term capability
@ -598,7 +598,7 @@ int FOptiMove::capDuration (const char cap[], int affcnt)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::capDurationToLength (int duration) int FOptiMove::capDurationToLength (int duration) const
{ {
if ( duration != LONG_DURATION ) if ( duration != LONG_DURATION )
return (duration + char_duration - 1) / char_duration; return (duration + char_duration - 1) / char_duration;
@ -609,7 +609,7 @@ int FOptiMove::capDurationToLength (int duration)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::repeatedAppend ( const capability& o int FOptiMove::repeatedAppend ( const capability& o
, volatile int count , volatile int count
, char* dst ) , char* dst ) const
{ {
const std::size_t src_len = std::strlen(o.cap); const std::size_t src_len = std::strlen(o.cap);
const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0; const std::size_t dst_len = ( dst != nullptr ) ? std::strlen(dst) : 0;
@ -641,7 +641,7 @@ int FOptiMove::repeatedAppend ( const capability& o
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FOptiMove::relativeMove ( char move[] int FOptiMove::relativeMove ( char move[]
, int from_x, int from_y , int from_x, int from_y
, int to_x, int to_y ) , int to_x, int to_y ) const
{ {
int vtime{0}; int vtime{0};
int htime{0}; int htime{0};
@ -680,7 +680,7 @@ int FOptiMove::relativeMove ( char move[]
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
{ {
int vtime{LONG_DURATION}; int vtime{LONG_DURATION};
@ -689,7 +689,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
if ( move ) if ( move )
{ {
std::strncpy ( move std::strncpy ( move
, FTermcap::encodeParameter(F_row_address.cap, to_y) , FTermcap::encodeParameter(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE ); , BUF_SIZE );
move[BUF_SIZE - 1] = '\0'; move[BUF_SIZE - 1] = '\0';
} }
@ -707,7 +707,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::downMove ( char move[], int& vtime inline void FOptiMove::downMove ( char move[], int& vtime
, int from_y, int to_y ) , int from_y, int to_y ) const
{ {
const int num = to_y - from_y; const int num = to_y - from_y;
@ -716,7 +716,7 @@ inline void FOptiMove::downMove ( char move[], int& vtime
if ( move ) if ( move )
{ {
std::strncpy ( move std::strncpy ( move
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num) , FTermcap::encodeParameter(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE ); , BUF_SIZE );
move[BUF_SIZE - 1] = '\0'; move[BUF_SIZE - 1] = '\0';
} }
@ -735,7 +735,7 @@ inline void FOptiMove::downMove ( char move[], int& vtime
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::upMove ( char move[], int& vtime inline void FOptiMove::upMove ( char move[], int& vtime
, int from_y, int to_y ) , int from_y, int to_y ) const
{ {
const int num = from_y - to_y; const int num = from_y - to_y;
@ -744,7 +744,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
if ( move ) if ( move )
{ {
std::strncpy ( move std::strncpy ( move
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num) , FTermcap::encodeParameter(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE ); , BUF_SIZE );
move[BUF_SIZE - 1] = '\0'; move[BUF_SIZE - 1] = '\0';
} }
@ -762,7 +762,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
{ {
int htime{LONG_DURATION}; int htime{LONG_DURATION};
@ -770,7 +770,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
{ {
// Move to fixed column position1 // Move to fixed column position1
std::strncat ( hmove std::strncat ( hmove
, FTermcap::encodeParameter(F_column_address.cap, to_x) , FTermcap::encodeParameter(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE - std::strlen(hmove) - 1 ); , BUF_SIZE - std::strlen(hmove) - 1 );
hmove[BUF_SIZE - 1] = '\0'; hmove[BUF_SIZE - 1] = '\0';
htime = F_column_address.duration; htime = F_column_address.duration;
@ -786,14 +786,14 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::rightMove ( char hmove[], int& htime inline void FOptiMove::rightMove ( char hmove[], int& htime
, int from_x, int to_x ) , int from_x, int to_x ) const
{ {
int num = to_x - from_x; int num = to_x - from_x;
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime ) if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
{ {
std::strncpy ( hmove std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num) , FTermcap::encodeParameter(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE - 1); , BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0'; hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_right_cursor.duration; htime = F_parm_right_cursor.duration;
@ -841,14 +841,14 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FOptiMove::leftMove ( char hmove[], int& htime inline void FOptiMove::leftMove ( char hmove[], int& htime
, int from_x, int to_x ) , int from_x, int to_x ) const
{ {
int num = from_x - to_x; int num = from_x - to_x;
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime ) if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
{ {
std::strncpy ( hmove std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num) , FTermcap::encodeParameter(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, BUF_SIZE - 1); , BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0'; hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_left_cursor.duration; htime = F_parm_left_cursor.duration;
@ -927,7 +927,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiMove::isMethod1Faster ( int& move_time inline bool FOptiMove::isMethod1Faster ( int& move_time
, int xold, int yold , int xold, int yold
, int xnew, int ynew ) , int xnew, int ynew ) const
{ {
// Test method 1: local movement // Test method 1: local movement
@ -949,7 +949,7 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiMove::isMethod2Faster ( int& move_time inline bool FOptiMove::isMethod2Faster ( int& move_time
, int yold , int yold
, int xnew, int ynew ) , int xnew, int ynew ) const
{ {
// Test method 2: carriage-return + local movement // Test method 2: carriage-return + local movement
@ -971,7 +971,7 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiMove::isMethod3Faster ( int& move_time inline bool FOptiMove::isMethod3Faster ( int& move_time
, int xnew, int ynew ) , int xnew, int ynew ) const
{ {
// Test method 3: home-cursor + local movement // Test method 3: home-cursor + local movement
@ -993,7 +993,7 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiMove::isMethod4Faster ( int& move_time inline bool FOptiMove::isMethod4Faster ( int& move_time
, int xnew, int ynew ) , int xnew, int ynew ) const
{ {
// Test method 4: home-down + local movement // Test method 4: home-down + local movement
if ( F_cursor_to_ll.cap ) if ( F_cursor_to_ll.cap )
@ -1017,7 +1017,7 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FOptiMove::isMethod5Faster ( int& move_time inline bool FOptiMove::isMethod5Faster ( int& move_time
, int yold , int yold
, int xnew, int ynew ) , int xnew, int ynew ) const
{ {
// Test method 5: left margin for wrap to right-hand side // Test method 5: left margin for wrap to right-hand side
if ( automatic_left_margin if ( automatic_left_margin

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fpoint.cpp - Point with an x and y coordinate * * fpoint.cpp - Point with an x and y coordinate *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <utility>
#include "final/fpoint.h" #include "final/fpoint.h"
namespace finalcut namespace finalcut

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fprogressbar.cpp - Widget FProgressbar * * fprogressbar.cpp - Widget FProgressbar *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -38,8 +38,7 @@ namespace finalcut
FProgressbar::FProgressbar(FWidget* parent) FProgressbar::FProgressbar(FWidget* parent)
: FWidget{parent} : FWidget{parent}
{ {
unsetFocusable(); init();
setShadow();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -133,6 +132,13 @@ void FProgressbar::reset()
// private methods of FProgressbar // private methods of FProgressbar
//----------------------------------------------------------------------
void FProgressbar::init()
{
unsetFocusable();
setShadow();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::draw() void FProgressbar::draw()
{ {
@ -198,7 +204,7 @@ std::size_t FProgressbar::drawProgressIndicator()
if ( len >= bar_length ) if ( len >= bar_length )
return len; return len;
if ( round(length) > len || FTerm::getMaxColor() < 16 ) if ( std::size_t(round(length)) > len || FTerm::getMaxColor() < 16 )
{ {
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(false); setReverse(false);

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fradiobutton.cpp - Widget FRadioButton * * fradiobutton.cpp - Widget FRadioButton *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -74,7 +74,7 @@ void FRadioButton::draw()
void FRadioButton::drawRadioButton() void FRadioButton::drawRadioButton()
{ {
print() << FPoint{1, 1}; print() << FPoint{1, 1};
useParentWidgetColor(); setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fradiomenuitem.cpp - Widget FRadioMenuItem * * fradiomenuitem.cpp - Widget FRadioMenuItem *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -20,6 +20,8 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include <utility>
#include "final/fc.h" #include "final/fc.h"
#include "final/fradiomenuitem.h" #include "final/fradiomenuitem.h"
#include "final/fmenu.h" #include "final/fmenu.h"
@ -36,14 +38,14 @@ namespace finalcut
FRadioMenuItem::FRadioMenuItem (FWidget* parent) FRadioMenuItem::FRadioMenuItem (FWidget* parent)
: FMenuItem{parent} : FMenuItem{parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent) FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent)
: FMenuItem{txt, parent} : FMenuItem{txt, parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -53,10 +55,11 @@ FRadioMenuItem::~FRadioMenuItem() // destructor
// private methods of FRadioMenuItem // private methods of FRadioMenuItem
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRadioMenuItem::init (FWidget* parent) void FRadioMenuItem::init()
{ {
setCheckable(); setCheckable();
setRadioButton(); setRadioButton();
FWidget* parent = getParentWidget();
if ( ! parent ) if ( ! parent )
return; return;
@ -69,13 +72,14 @@ void FRadioMenuItem::init (FWidget* parent)
addCallback // for this element addCallback // for this element
( (
"toggled", "toggled",
F_METHOD_CALLBACK (menu_ptr, &FMenu::cb_menuitemToggled) std::move(menu_ptr), &FMenu::cb_menuitemToggled,
this
); );
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRadioMenuItem::processToggle() void FRadioMenuItem::processToggle() const
{ {
emitCallback("toggled"); emitCallback("toggled");
} }

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* frect.cpp - Rectangle with position and size * * frect.cpp - Rectangle with position and size *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <algorithm> #include <algorithm>
#include <utility>
#include "final/fpoint.h" #include "final/fpoint.h"
#include "final/frect.h" #include "final/frect.h"

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fscrollbar.cpp - Widget FScrollbar * * fscrollbar.cpp - Widget FScrollbar *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2012-2020 Markus Gans * * Copyright 2012-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -55,7 +55,7 @@ FScrollbar::FScrollbar(fc::orientation o, FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::~FScrollbar() // destructor FScrollbar::~FScrollbar() // destructor
{ {
delOwnTimer(); delOwnTimers();
} }
@ -305,7 +305,7 @@ void FScrollbar::onMouseUp (FMouseEvent* ev)
if ( scroll_type != FScrollbar::noScroll ) if ( scroll_type != FScrollbar::noScroll )
{ {
delOwnTimer(); delOwnTimers();
scroll_type = FScrollbar::noScroll; scroll_type = FScrollbar::noScroll;
} }
} }
@ -360,7 +360,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
if ( mouse_x < 1 || mouse_x > int(getWidth()) if ( mouse_x < 1 || mouse_x > int(getWidth())
|| mouse_y < 1 || mouse_y > int(getHeight()) ) || mouse_y < 1 || mouse_y > int(getHeight()) )
{ {
delOwnTimer(); delOwnTimers();
} }
else if ( scroll_type != FScrollbar::scrollJump ) else if ( scroll_type != FScrollbar::scrollJump )
{ {
@ -369,7 +369,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
if ( scroll_type != new_scroll_type ) if ( scroll_type != new_scroll_type )
{ {
delOwnTimer(); delOwnTimers();
} }
} }
@ -380,7 +380,7 @@ void FScrollbar::onWheel (FWheelEvent* ev)
if ( scroll_type != FScrollbar::noScroll ) if ( scroll_type != FScrollbar::noScroll )
{ {
delOwnTimer(); delOwnTimers();
scroll_type = FScrollbar::noScroll; scroll_type = FScrollbar::noScroll;
} }
@ -401,7 +401,7 @@ void FScrollbar::onTimer (FTimerEvent*)
if ( ! threshold_reached ) if ( ! threshold_reached )
{ {
threshold_reached = true; threshold_reached = true;
delOwnTimer(); delOwnTimers();
addTimer(repeat_time); addTimer(repeat_time);
} }
@ -426,7 +426,7 @@ void FScrollbar::onTimer (FTimerEvent*)
processScroll(); processScroll();
} }
delOwnTimer(); delOwnTimers();
return; return;
} }
@ -453,6 +453,7 @@ void FScrollbar::draw()
drawButtons(); drawButtons();
current_slider_pos = -1; current_slider_pos = -1;
max_color = FTerm::getMaxColor();
drawBar(); drawBar();
} }
@ -513,7 +514,7 @@ inline void FScrollbar::drawVerticalBackgroundLine()
print (fc::MediumShade); // ▒ print (fc::MediumShade); // ▒
else if ( FTerm::isNewFont() ) else if ( FTerm::isNewFont() )
print (fc::NF_rev_border_line_right); //⎹ print (fc::NF_rev_border_line_right); //⎹
else else
print (' '); print (' ');
} }
@ -612,7 +613,7 @@ void FScrollbar::drawButtons()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) const
{ {
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
@ -625,7 +626,7 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y) FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y) const
{ {
if ( y == 1 ) if ( y == 1 )
{ {
@ -648,7 +649,7 @@ FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x) FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x) const
{ {
if ( FTerm::isNewFont() ) if ( FTerm::isNewFont() )
{ {
@ -695,7 +696,7 @@ FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y) int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y) const
{ {
// Get the clicked position on the slider // Get the clicked position on the slider
@ -731,9 +732,9 @@ void FScrollbar::jumpToClickPos (int x, int y)
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
if ( y >1 && y < int(getHeight()) ) if ( y > 1 && y < int(getHeight()) )
{ {
new_val = int( round ( double(max - min) * (y - 2.0 - (slider_length/2)) new_val = int( round ( double(max - min) * (y - 2.0 - double(slider_length/2))
/ double(bar_length - slider_length) ) ); / double(bar_length - slider_length) ) );
} }
else else
@ -745,7 +746,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
if ( x > 1 + nf && x < int(getWidth()) - nf ) if ( x > 1 + nf && x < int(getWidth()) - nf )
{ {
new_val = int( round ( double(max - min) * (x - 2.0 - nf - (slider_length/2)) new_val = int( round ( double(max - min) * (x - 2.0 - nf - double(slider_length/2))
/ double(bar_length - slider_length) ) ); / double(bar_length - slider_length) ) );
} }
else else
@ -786,7 +787,7 @@ void FScrollbar::avoidScrollOvershoot()
&& slider_pos > slider_click_stop_pos ) ) && slider_pos > slider_click_stop_pos ) )
{ {
jumpToClickPos (slider_click_stop_pos); jumpToClickPos (slider_click_stop_pos);
delOwnTimer(); delOwnTimers();
} }
} }

View File

@ -2,17 +2,17 @@
* fscrollview.cpp - Widget FScrollView (a scrolling area with * * fscrollview.cpp - Widget FScrollView (a scrolling area with *
* on-demand scroll bars) * * on-demand scroll bars) *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2017-2020 Markus Gans * * Copyright 2017-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -40,7 +40,7 @@ namespace finalcut
FScrollView::FScrollView (FWidget* parent) FScrollView::FScrollView (FWidget* parent)
: FWidget{parent} : FWidget{parent}
{ {
init(parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -694,7 +694,7 @@ void FScrollView::copy2area()
// private methods of FScrollView // private methods of FScrollView
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint FScrollView::getViewportCursorPos() inline const FPoint FScrollView::getViewportCursorPos() const
{ {
const auto& window = FWindow::getWindowWidget(this); const auto& window = FWindow::getWindowWidget(this);
@ -713,8 +713,10 @@ inline const FPoint FScrollView::getViewportCursorPos()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::init (const FWidget* parent) void FScrollView::init()
{ {
const FWidget* parent = getParentWidget();
assert ( parent != nullptr ); assert ( parent != nullptr );
assert ( ! parent->isInstanceOf("FScrollView") ); assert ( ! parent->isInstanceOf("FScrollView") );
@ -771,7 +773,7 @@ inline void FScrollView::mapKeyFunctions()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::calculateScrollbarPos() void FScrollView::calculateScrollbarPos() const
{ {
const std::size_t width = getWidth(); const std::size_t width = getWidth();
const std::size_t height = getHeight(); const std::size_t height = getHeight();
@ -792,7 +794,7 @@ void FScrollView::calculateScrollbarPos()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setHorizontalScrollBarVisibility() void FScrollView::setHorizontalScrollBarVisibility() const
{ {
assert ( v_mode == fc::Auto assert ( v_mode == fc::Auto
|| v_mode == fc::Hidden || v_mode == fc::Hidden
@ -818,7 +820,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setVerticalScrollBarVisibility() void FScrollView::setVerticalScrollBarVisibility() const
{ {
assert ( v_mode == fc::Auto assert ( v_mode == fc::Auto
|| v_mode == fc::Hidden || v_mode == fc::Hidden
@ -844,7 +846,7 @@ void FScrollView::setVerticalScrollBarVisibility()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setViewportCursor() void FScrollView::setViewportCursor() const
{ {
if ( ! isChild(getFocusWidget()) ) if ( ! isChild(getFocusWidget()) )
return; return;
@ -864,7 +866,7 @@ void FScrollView::setViewportCursor()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_vbarChange (const FWidget*, const FDataPtr) void FScrollView::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::sType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
@ -923,7 +925,7 @@ void FScrollView::cb_vbarChange (const FWidget*, const FDataPtr)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_hbarChange (const FWidget*, const FDataPtr) void FScrollView::cb_hbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::sType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fsize.cpp - Height and width of a two-dimensional surface * * fsize.cpp - Height and width of a two-dimensional surface *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <limits> #include <limits>
#include <utility>
#include "final/fpoint.h" #include "final/fpoint.h"
#include "final/fsize.h" #include "final/fsize.h"

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fspinbox.cpp - Widget FSpinBox * * fspinbox.cpp - Widget FSpinBox *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -235,13 +235,13 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
addTimer(threshold_time); addTimer(threshold_time);
} }
else else
delOwnTimer(); delOwnTimers();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSpinBox::onMouseUp (FMouseEvent*) void FSpinBox::onMouseUp (FMouseEvent*)
{ {
delOwnTimer(); delOwnTimers();
spining_state = FSpinBox::noSpin; spining_state = FSpinBox::noSpin;
} }
@ -250,7 +250,7 @@ void FSpinBox::onWheel (FWheelEvent* ev)
{ {
const int wheel = ev->getWheel(); const int wheel = ev->getWheel();
delOwnTimer(); delOwnTimers();
forceFocus(); forceFocus();
spining_state = FSpinBox::noSpin; spining_state = FSpinBox::noSpin;
@ -277,7 +277,7 @@ void FSpinBox::onTimer (FTimerEvent*)
if ( ! threshold_reached ) if ( ! threshold_reached )
{ {
threshold_reached = true; threshold_reached = true;
delOwnTimer(); delOwnTimers();
addTimer(repeat_time); addTimer(repeat_time);
} }
@ -317,9 +317,15 @@ void FSpinBox::init()
input_field.unsetShadow(); input_field.unsetShadow();
input_field << value; input_field << value;
input_field.addCallback input_field.addCallback
(
"activate",
this, &FSpinBox::cb_inputFieldActivate
);
input_field.addCallback
( (
"changed", "changed",
F_METHOD_CALLBACK (this, &FSpinBox::cb_inputFieldChange) this, &FSpinBox::cb_inputFieldChange,
std::cref(input_field)
); );
} }
@ -377,7 +383,7 @@ inline void FSpinBox::increaseValue()
processChanged(); processChanged();
} }
else else
delOwnTimer(); delOwnTimers();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -389,11 +395,17 @@ inline void FSpinBox::decreaseValue()
processChanged(); processChanged();
} }
else else
delOwnTimer(); delOwnTimers();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSpinBox::processChanged() void FSpinBox::processActivate() const
{
emitCallback("activate");
}
//----------------------------------------------------------------------
void FSpinBox::processChanged() const
{ {
emitCallback("changed"); emitCallback("changed");
} }
@ -417,17 +429,21 @@ void FSpinBox::forceFocus()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FSpinBox::cb_inputFieldChange (finalcut::FWidget* w, const FDataPtr) void FSpinBox::cb_inputFieldActivate() const
{ {
const auto& lineedit = static_cast<FLineEdit*>(w); processActivate();
}
if ( lineedit->getText().isEmpty() ) //----------------------------------------------------------------------
void FSpinBox::cb_inputFieldChange (const FLineEdit& lineedit)
{
if ( lineedit.getText().isEmpty() )
value = 0; value = 0;
else else
{ {
std::wregex regex(L"[-]?[[:xdigit:]]+"); std::wregex regex(L"[-]?[[:xdigit:]]+");
std::wsmatch match; std::wsmatch match;
std::wstring text = lineedit->getText().wc_str(); std::wstring text = lineedit.getText().wc_str();
if ( std::regex_search(text, match, regex) ) if ( std::regex_search(text, match, regex) )
{ {

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fstartoptions.cpp - Contains the start options for initialization * * fstartoptions.cpp - Contains the start options for initialization *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *

View File

@ -1,17 +1,17 @@
/*********************************************************************** /***********************************************************************
* fstatusbar.cpp - Widget FStatusBar and FStatusKey * * fstatusbar.cpp - Widget FStatusBar and FStatusKey *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2014-2020 Markus Gans * * Copyright 2014-2020 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * FINAL CUT is free software; you can redistribute it and/or modify *
* modify it under the terms of the GNU Lesser General Public License * * it under the terms of the GNU Lesser General Public License as *
* as published by the Free Software Foundation; either version 3 of * * published by the Free Software Foundation; either version 3 of *
* the License, or (at your option) any later version. * * the License, or (at your option) any later version. *
* * * *
* The Final Cut is distributed in the hope that it will be useful, * * FINAL CUT is distributed in the hope that it will be useful, but *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. * * GNU Lesser General Public License for more details. *
* * * *
@ -38,7 +38,7 @@ namespace finalcut
FStatusKey::FStatusKey(FWidget* parent) FStatusKey::FStatusKey(FWidget* parent)
: FWidget{parent} : FWidget{parent}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -47,7 +47,7 @@ FStatusKey::FStatusKey (FKey k, const FString& txt, FWidget* parent)
, text{txt} , text{txt}
, key{k} , key{k}
{ {
init (parent); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -99,9 +99,10 @@ bool FStatusKey::setMouseFocus(bool enable)
// private methods of FStatusKey // private methods of FStatusKey
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent) void FStatusKey::init()
{ {
setGeometry (FPoint{1, 1}, FSize{1, 1}); setGeometry (FPoint{1, 1}, FSize{1, 1});
FWidget* parent = getParentWidget();
if ( parent && parent->isInstanceOf("FStatusBar") ) if ( parent && parent->isInstanceOf("FStatusBar") )
{ {
@ -113,7 +114,7 @@ void FStatusKey::init (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::processActivate() void FStatusKey::processActivate() const
{ {
emitCallback("activate"); emitCallback("activate");
} }
@ -272,7 +273,9 @@ void FStatusBar::insert (FStatusKey* skey)
skey->addCallback skey->addCallback
( (
"activate", "activate",
F_METHOD_CALLBACK (this, &FStatusBar::cb_statuskey_activated) this,
&FStatusBar::cb_statuskey_activated,
skey
); );
} }
@ -485,11 +488,13 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::cb_statuskey_activated (FWidget* widget, const FDataPtr) void FStatusBar::cb_statuskey_activated (const FStatusKey* statuskey)
{ {
if ( ! statuskey )
return;
if ( ! key_list.empty() ) if ( ! key_list.empty() )
{ {
const auto& statuskey = static_cast<FStatusKey*>(widget);
auto iter = key_list.begin(); auto iter = key_list.begin();
const auto& last = key_list.end(); const auto& last = key_list.end();
@ -527,14 +532,14 @@ void FStatusBar::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FStatusBar::getKeyNameWidth (const FStatusKey* key) int FStatusBar::getKeyNameWidth (const FStatusKey* key) const
{ {
const FString& key_name = FTerm::getKeyName(key->getKey()); const FString& key_name = FTerm::getKeyName(key->getKey());
return int(getColumnWidth(key_name)); return int(getColumnWidth(key_name));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FStatusBar::getKeyTextWidth (const FStatusKey* key) int FStatusBar::getKeyTextWidth (const FStatusKey* key) const
{ {
const FString& key_text = key->getText(); const FString& key_text = key->getText();
return int(getColumnWidth(key_text)); return int(getColumnWidth(key_text));

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