From 219ac28fb742c1ea9aa5ea09c719fe05acc0096a Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 6 Jul 2020 19:32:01 +0200 Subject: [PATCH] Add a document that describes how to create user themes --- ChangeLog | 3 + README.md | 38 +-- configure.ac | 21 +- doc/mouse-control.md | 29 ++ doc/user-theme-bee-palette.svg | 330 ++++++++++++++++++++ doc/user-theme-fc16-dark-palette.svg | 330 ++++++++++++++++++++ doc/user-theme-fc16-palette.svg | 330 ++++++++++++++++++++ doc/user-theme-fc8-palette.svg | 194 ++++++++++++ doc/user-theme-vga-palette.svg | 330 ++++++++++++++++++++ doc/user-theme.md | 436 +++++++++++++++++++++++++++ doc/user-theme.png | Bin 0 -> 1593 bytes examples/timer.cpp | 2 +- m4/cppunit.m4 | 92 ------ src/fapplication.cpp | 14 +- src/fbusyindicator.cpp | 10 +- src/fcheckmenuitem.cpp | 7 +- src/fcolorpalette.cpp | 8 +- src/fkeyboard.cpp | 2 +- src/fmenu.cpp | 24 +- src/fmenuitem.cpp | 9 +- src/fmessagebox.cpp | 64 ++-- src/foptiattr.cpp | 10 +- src/foptimove.cpp | 28 +- src/fprogressbar.cpp | 10 +- src/fradiomenuitem.cpp | 7 +- src/fscrollview.cpp | 6 +- src/fstatusbar.cpp | 7 +- src/fstring.cpp | 8 +- src/fterm.cpp | 47 ++- src/fterm_functions.cpp | 4 +- src/ftermxterminal.cpp | 16 +- src/fvterm.cpp | 10 +- src/fwidget.cpp | 39 ++- src/fwidget_functions.cpp | 2 +- src/include/final/fapplication.h | 2 +- src/include/final/fbusyindicator.h | 1 + src/include/final/fcheckmenuitem.h | 2 +- src/include/final/fmenu.h | 2 +- src/include/final/fmenuitem.h | 2 +- src/include/final/fmessagebox.h | 4 +- src/include/final/fprogressbar.h | 1 + src/include/final/fradiomenuitem.h | 2 +- src/include/final/fscrollview.h | 2 +- src/include/final/fstatusbar.h | 2 +- src/include/final/fterm.h | 6 +- src/include/final/fwidget.h | 3 + src/include/final/fwidgetcolors.h | 30 ++ test/ftermdetection-test.cpp | 2 +- 48 files changed, 2265 insertions(+), 263 deletions(-) create mode 100644 doc/mouse-control.md create mode 100644 doc/user-theme-bee-palette.svg create mode 100644 doc/user-theme-fc16-dark-palette.svg create mode 100644 doc/user-theme-fc16-palette.svg create mode 100644 doc/user-theme-fc8-palette.svg create mode 100644 doc/user-theme-vga-palette.svg create mode 100644 doc/user-theme.md create mode 100644 doc/user-theme.png delete mode 100644 m4/cppunit.m4 diff --git a/ChangeLog b/ChangeLog index d7dde9c4..601a0bec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2020-07-06 Markus Gans + * Add a document that describes how to create user themes + 2020-06-11 Markus Gans * New widget FBusyIndicator to indicate background activity * Added example/busy to demonstrate the functionality of this widget diff --git a/README.md b/README.md index fdf8f635..a4fbc267 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ ![FINAL CUT](logo/svg/finalcut-logo.svg) # 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. ## Building and code analysis + | | Badge | |-------------------:|:------| | *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) | ## Installation + ```bash > git clone git://github.com/gansm/finalcut.git > cd finalcut @@ -28,6 +31,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla ``` ## Supported platforms + * Linux * FreeBSD * NetBSD @@ -37,6 +41,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla * Solaris ## 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. ## Some screenshots @@ -45,46 +50,38 @@ The FFileDialog widget with incremental file name search: ![FFileDialog](doc/fileopen-dialog.png) - The FINAL CUT FProgressbar widget: ![FProgressbar](doc/progress-bar.png) - Scrollable text in the FTextView widget: ![FTextView](doc/textview.png) - The Mandelbrot set example: ![Mandelbrot set](doc/Mandelbrot.png) +## newfont -newfont -------- A [graphical text font](fonts/) for X11 and the Linux console. ![ui example in newfont mode](doc/newfont1.png) - Newfont drive symbols: ![drive symbols](doc/newfont2.png) - The calculator example in newfont mode: ![calculator](doc/calculator.png) +## Benchmark -Benchmark ---------- 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.
@@ -136,9 +133,7 @@ printf(...)
                                                ▀▀▀▀▀▀▀▀▀
 
- -Class digramm -------------- +## Class digramm
               1┌──────────────┐
@@ -254,15 +249,14 @@ Class digramm
                                                      └────────────────┘
 
-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). -Please send bug reports to --------------------------- +## Please send bug reports to + https://github.com/gansm/finalcut/issues -License -------- -GNU Lesser General Public License Version 3 LGPLv3 +## License +GNU Lesser General Public License Version 3 LGPLv3 diff --git a/configure.ac b/configure.ac index 47f6e80d..2eb274dc 100644 --- a/configure.ac +++ b/configure.ac @@ -86,9 +86,9 @@ AX_CHECK_COMPILE_FLAG([[-std=c++11]],, # use GPM (General Purpose Mouse) AC_ARG_WITH([gpm], [AS_HELP_STRING([--without-gpm], [Disable GPM mouse support])], - [with_gpm=no], + [], [with_gpm=yes]) -if test "x$with_gpm" = "xyes" +if test "x$with_gpm" != "xno" then AC_CHECK_LIB([gpm], [main], @@ -99,9 +99,9 @@ fi # profiling AC_ARG_WITH([profiler], [AS_HELP_STRING([--with-profiler], [build extra google profiler binaries])], - [with_profiler=yes], + [], [with_profiler=no]) -if test "x$with_profiler" = "xyes" +if test "x$with_profiler" != "xno" then AC_CHECK_LIB([profiler], [ProfilerFlush], @@ -111,14 +111,13 @@ fi # unit test AC_ARG_WITH([unit-test], [AS_HELP_STRING([--with-unit-test], [build unit tests])], - [with_unit_test=yes], + [], [with_unit_test=no]) -if test "x$with_unit_test" = "xyes" +if test "x$with_unit_test" != "xno" then AC_MSG_NOTICE(enabled cppunit test) - AM_PATH_CPPUNIT([1.12.0], - [], - [AC_MSG_ERROR([*** CppUnit not found! ***])]) + PKG_CHECK_MODULES(CPPUNIT, + [cppunit > 1.12.0]) AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "1"]) else AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"]) @@ -128,9 +127,9 @@ fi # code coverage AC_ARG_WITH([gcov], [AS_HELP_STRING([--with-gcov], [build for code coverage testing])], - [with_gcov=yes], + [], [with_gcov=no]) -if test "x$with_gcov" = "xyes" +if test "x$with_gcov" != "xno" then AC_CHECK_LIB([gcov], [main], diff --git a/doc/mouse-control.md b/doc/mouse-control.md new file mode 100644 index 00000000..03ca4b70 --- /dev/null +++ b/doc/mouse-control.md @@ -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. + diff --git a/doc/user-theme-bee-palette.svg b/doc/user-theme-bee-palette.svg new file mode 100644 index 00000000..90825aa4 --- /dev/null +++ b/doc/user-theme-bee-palette.svg @@ -0,0 +1,330 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + diff --git a/doc/user-theme-fc16-dark-palette.svg b/doc/user-theme-fc16-dark-palette.svg new file mode 100644 index 00000000..0d91e4d3 --- /dev/null +++ b/doc/user-theme-fc16-dark-palette.svg @@ -0,0 +1,330 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + diff --git a/doc/user-theme-fc16-palette.svg b/doc/user-theme-fc16-palette.svg new file mode 100644 index 00000000..7bcadf23 --- /dev/null +++ b/doc/user-theme-fc16-palette.svg @@ -0,0 +1,330 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + diff --git a/doc/user-theme-fc8-palette.svg b/doc/user-theme-fc8-palette.svg new file mode 100644 index 00000000..0578c6a1 --- /dev/null +++ b/doc/user-theme-fc8-palette.svg @@ -0,0 +1,194 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + diff --git a/doc/user-theme-vga-palette.svg b/doc/user-theme-vga-palette.svg new file mode 100644 index 00000000..e451e02c --- /dev/null +++ b/doc/user-theme-vga-palette.svg @@ -0,0 +1,330 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + diff --git a/doc/user-theme.md b/doc/user-theme.md new file mode 100644 index 00000000..b3f699b8 --- /dev/null +++ b/doc/user-theme.md @@ -0,0 +1,436 @@ +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(); +``` + +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(); +``` +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. +
+ VGA palette +
Figure 1. VGA palette
+
+ +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. +
+ FINAL CUT 8-color palette +
Figure 2. FINAL CUT 8-color palette
+
+ +The FINAL CUT palette `default16ColorPalette` is the default 16-color +palette. It is optimized for the widget color theme `default16ColorTheme`. +
+ FINAL CUT 16-color palette +
Figure 3. FINAL CUT 16-color palette
+
+ +The second 16-color palette in FINAL CUT is for the dark theme. It was +adjusted for the widget color themes `default8ColorDarkTheme` and +`default16ColorDarkTheme`. +
+ FINAL CUT 16-color dark palette +
Figure 4. FINAL CUT 16-color dark palette
+
+ +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. +
+ Bee palette +
Figure 6. Bee palette
+
+ +**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. +
+ User theme example +
Figure 7. User theme example
+
+ + +**File:** *theme.cpp* +```cpp +#include + +#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", + F_METHOD_CALLBACK (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", + F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) + ); + Open.addCallback + ( + "clicked", + F_METHOD_CALLBACK (this, &dialogWidget::cb_FileBrowse) + ); + } + + private: + void cb_FileBrowse (finalcut::FWidget*, FDataPtr) + { + 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(); + + // Set the color palette theme + FTerm::setColorPaletteTheme(); + + 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 + +``` diff --git a/doc/user-theme.png b/doc/user-theme.png new file mode 100644 index 0000000000000000000000000000000000000000..47019aab15d076bf56e7cdff50e395df8d2eb0eb GIT binary patch literal 1593 zcmeAS@N?(olHy`uVBq!ia0y~yU}|DuU~FPx28y(q?cWWg6a#!hT!FNbg0||UYD-hI zB}+E!l$1QTY5DheOaJ|P{O{kt|Ns9h3Wb#d6)`4xySp%Su*!M>Ih+L^k;M!Q+`=Ht z$S`Y;1W=H@#M9T6{Rul8gCJA(T%#il46O4!T^vIyZoR#0pZ~~1f<3`|yI01OrJ|zZd6Bo?0Ne#*k<~+bGA#)KYjW~`(V3CY;e@J_X0kg z+gLBlHfbLG+vFcQckA+FH|D8)jQOdFWq}yxk2*i_0qGUZ?8+c70!@<{jIG2 z^Mh3V~8!&4tWJ#Qg>P{s3~_`$%K+A!AB-#&}I32Ht%Yfq@bn(K@A%rw~CYibd*`eYqv zT46@s>Vt{KPMrTt4hEiQJsc&&;$B%h=lbNh&FlI;J++Bge{|u>JFC80f79=;R@(9R z?J2t-ecS6;INwzto+J3><{5X^^Om1q{V)9I1`041PN6q*6N(rmYgRsZz@!BgQUM2M zy1vBzpMh`Av$NQ%S*(!fC=;wvz2RFBclCjdWQel$o-GIWRN2Me6`sjHJ1}O?f?uty z*MGiFhoBWX-;bl2_S6d9UTN@UK32-SlAN)F;L)XPbXtd$i;p zTlVJ#TW{>P0=eUk=8vM{T|3v#`8RX#dHyDGjUBIkI8AsU-k;Ru&UH_$KhZo#-+a5d zx{>X?n;LvYUzf3Q3ibTdtvg;6TM)HXcu&c}Z)IFf;aAHhHEmySe%f@$jG9+$P44&k z=iP|jQ!I6qrGDLm_xbtx|ApRsxXE*{cK(KQ{=dre%=Wv1Y=?OH-_f~{K!I@K;z*2n z^B%m~uD1QD`|@lKA)9~?g+=#kTED+CIQZ1`Y`)`{h!1t&Zpg@J?AX(m5PnedV34xs zx<_W+^~=~f+v*ap9DiMh`te^=i|qUS=c?kG`;SJ|)GtZc)AnGS)Eu+&6V_P; z%h>uaE9{u}bK?He;y=<=4}E?tly_hDY4OLuX6-xQ%$P3IdZ_rGPebvG<0tm3CxRqks>%u(N=CUNa)+O6pI2dnPtEj=w2v+gO2`1|R1jvfoF*{*iuF>Bic z^?QNtYagAnTz6FZ*};O~*u3tol^3FPfPQ$haY4zM`p->DzTJxVe*+6|22WQ%mvv4F FO#n#=zMcR8 literal 0 HcmV?d00001 diff --git a/examples/timer.cpp b/examples/timer.cpp index 3b444c8c..032807e4 100644 --- a/examples/timer.cpp +++ b/examples/timer.cpp @@ -35,7 +35,7 @@ class Timer final : public finalcut::FWidget // Constructor explicit Timer (finalcut::FWidget* = nullptr); - protected: + private: // Method void draw() override; diff --git a/m4/cppunit.m4 b/m4/cppunit.m4 deleted file mode 100644 index 41f067b6..00000000 --- a/m4/cppunit.m4 +++ /dev/null @@ -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) -]) - - - diff --git a/src/fapplication.cpp b/src/fapplication.cpp index efade18f..4177e28c 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -96,7 +96,7 @@ FApplication::FApplication (const int& _argc, char* _argv[]) app_argv = reinterpret_cast(&empty_str); } - init (key_timeout, dblclick_interval); + init(); } //---------------------------------------------------------------------- @@ -278,14 +278,14 @@ void FApplication::setDefaultTheme() if ( FTerm::getMaxColor() < 16 ) // for 8 color mode { if ( getStartOptions().color_change ) - FTerm::setColorPaletteTheme(&FTerm::setPalette); + FTerm::setColorPaletteTheme(); setColorTheme(); } else { if ( getStartOptions().color_change ) - FTerm::setColorPaletteTheme(&FTerm::setPalette); + FTerm::setColorPaletteTheme(); setColorTheme(); } @@ -295,7 +295,7 @@ void FApplication::setDefaultTheme() void FApplication::setDarkTheme() { if ( getStartOptions().color_change ) - FTerm::setColorPaletteTheme(&FTerm::setPalette); + FTerm::setColorPaletteTheme(); if ( FTerm::getMaxColor() < 16 ) // for 8 color mode setColorTheme(); @@ -335,7 +335,7 @@ void FApplication::processExternalUserEvent() // private methods of FApplication //---------------------------------------------------------------------- -void FApplication::init (uInt64 key_time, uInt64 dblclick_time) +void FApplication::init() { // Initialize keyboard keyboard = FTerm::getFKeyboard(); @@ -352,7 +352,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time) keyboard->setPressCommand (key_cmd1); keyboard->setReleaseCommand (key_cmd2); keyboard->setEscPressedCommand (key_cmd3); - keyboard->setKeypressTimeout (key_time); + keyboard->setKeypressTimeout (key_timeout); } // Initialize mouse control @@ -364,7 +364,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time) // Set the default double click interval if ( mouse ) - mouse->setDblclickInterval (dblclick_time); + mouse->setDblclickInterval (dblclick_interval); // Initialize logging if ( ! getStartOptions().logfile_stream.is_open() ) diff --git a/src/fbusyindicator.cpp b/src/fbusyindicator.cpp index 0b7ce8ee..dcd2f5a6 100644 --- a/src/fbusyindicator.cpp +++ b/src/fbusyindicator.cpp @@ -34,8 +34,7 @@ namespace finalcut FBusyIndicator::FBusyIndicator (FWidget* parent) : FToolTip{parent} { - FToolTip::hide(); - createIndicatorText(); + init(); } //---------------------------------------------------------------------- @@ -66,6 +65,13 @@ void FBusyIndicator::stop() // private methods of FBusyIndicator +//---------------------------------------------------------------------- +void FBusyIndicator::init() +{ + FToolTip::hide(); + createIndicatorText(); +} + //---------------------------------------------------------------------- void FBusyIndicator::createIndicatorText() { diff --git a/src/fcheckmenuitem.cpp b/src/fcheckmenuitem.cpp index 201d4e05..392ca681 100644 --- a/src/fcheckmenuitem.cpp +++ b/src/fcheckmenuitem.cpp @@ -36,14 +36,14 @@ namespace finalcut FCheckMenuItem::FCheckMenuItem (FWidget* parent) : FMenuItem{parent} { - init (parent); + init(); } //---------------------------------------------------------------------- FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent) : FMenuItem{txt, parent} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -53,9 +53,10 @@ FCheckMenuItem::~FCheckMenuItem() // destructor // private methods of FCheckMenuItem //---------------------------------------------------------------------- -void FCheckMenuItem::init (FWidget* parent) +void FCheckMenuItem::init() { setCheckable(); + FWidget* parent = getParentWidget(); if ( ! parent ) return; diff --git a/src/fcolorpalette.cpp b/src/fcolorpalette.cpp index d061d767..e173218d 100644 --- a/src/fcolorpalette.cpp +++ b/src/fcolorpalette.cpp @@ -53,10 +53,10 @@ void FColorPalette::setVGAdefaultPalette() setPalette (fc::Black, 0x00, 0x00, 0x00); setPalette (fc::Blue, 0x00, 0x00, 0xaa); setPalette (fc::Green, 0x00, 0xaa, 0x00); - setPalette (fc::Cyan, 0x00, 0x55, 0xaa); + setPalette (fc::Cyan, 0x00, 0xaa, 0xaa); setPalette (fc::Red, 0xaa, 0x00, 0x00); 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::DarkGray, 0x55, 0x55, 0x55); setPalette (fc::LightBlue, 0x55, 0x55, 0xff); @@ -126,7 +126,7 @@ default16ColorPalette::default16ColorPalette (const FSetPalette& f) default16ColorPalette::~default16ColorPalette() { } -// public methods of default8ColorPalette +// public methods of default16ColorPalette //---------------------------------------------------------------------- void default16ColorPalette::setColorPalette() { @@ -169,7 +169,7 @@ default16DarkColorPalette::default16DarkColorPalette (const FSetPalette& f) default16DarkColorPalette::~default16DarkColorPalette() { } -// public methods of default8ColorPalette +// public methods of default16DarkColorPalette //---------------------------------------------------------------------- void default16DarkColorPalette::setColorPalette() { diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index d058f5d2..35b6e005 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -124,7 +124,7 @@ bool FKeyboard::isKeyPressed() const FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); 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 const int result = select (stdin_no + 1, &ifds, nullptr, nullptr, &tv); if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 060bc3d1..ebca38b4 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -47,7 +47,7 @@ namespace finalcut FMenu::FMenu(FWidget* parent) : FWindow{parent} { - init(parent); + init(); } //---------------------------------------------------------------------- @@ -55,7 +55,7 @@ FMenu::FMenu (const FString& txt, FWidget* parent) : FWindow{parent} , menuitem{txt, parent} { - init(parent); + init(); } //---------------------------------------------------------------------- @@ -457,7 +457,7 @@ bool FMenu::isMouseOverMenuBar (const FPoint& termpos) } //---------------------------------------------------------------------- -void FMenu::init(FWidget* parent) +void FMenu::init() { setTopPadding(1); setLeftPadding(1); @@ -469,6 +469,7 @@ void FMenu::init(FWidget* parent) hide(); resetColors(); menuitem.setMenu(this); + FWidget* parent = getParentWidget(); if ( parent ) { @@ -1428,15 +1429,16 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key) const FString accel_name {FTerm::getKeyName(accel_key)}; const std::size_t c = ( has_checkable_items ) ? 1 : 0; const std::size_t 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 ) - { - // Print filling blank spaces + accelerator key name - const FString spaces {len, L' '}; - print (spaces + accel_name); - startpos = max_item_width - (c + 2); - } + if ( plain_text_length >= max_item_width ) + return; + + // Print filling blank spaces + accelerator key name + const std::size_t len = max_item_width - plain_text_length; + const FString spaces {len, L' '}; + print (spaces + accel_name); + startpos = max_item_width - (c + 2); } //---------------------------------------------------------------------- diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 2bbc12db..25b750f6 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -44,7 +44,7 @@ namespace finalcut FMenuItem::FMenuItem (FWidget* parent) : FWidget{parent} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -52,7 +52,7 @@ FMenuItem::FMenuItem (const FString& txt, FWidget* parent) : FWidget{parent} , text{txt} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -61,7 +61,7 @@ FMenuItem::FMenuItem (FKey k, const FString& txt, FWidget* parent) , text{txt} , accel_key{k} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -503,7 +503,7 @@ FMenuList* FMenuItem::getFMenuList (FWidget& widget) } //---------------------------------------------------------------------- -void FMenuItem::init (FWidget* parent) +void FMenuItem::init() { text_length = text.getLength(); text_width = getColumnWidth(text); @@ -519,6 +519,7 @@ void FMenuItem::init (FWidget* parent) } setGeometry (FPoint{1, 1}, FSize{text_width + 2, 1}, false); + FWidget* parent = getParentWidget(); if ( ! parent ) return; diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index d47b1e4d..f156bfe7 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -51,9 +51,10 @@ static const char* const button_text[] = //---------------------------------------------------------------------- FMessageBox::FMessageBox (FWidget* parent) : FDialog{parent} + , button_digit{FMessageBox::Ok, 0, 0} { setTitlebarText("Message for you"); - init(FMessageBox::Ok, 0, 0); + init(); } //---------------------------------------------------------------------- @@ -64,14 +65,15 @@ FMessageBox::FMessageBox (const FMessageBox& mbox) , text_components{mbox.text_components} , max_line_width{mbox.max_line_width} , emphasis_color{mbox.emphasis_color} + , button_digit{mbox.button_digit[0], + mbox.button_digit[1], + mbox.button_digit[2]} , num_buttons{mbox.num_buttons} , text_num_lines{mbox.text_num_lines} , center_text{mbox.center_text} { setTitlebarText (mbox.getTitlebarText()); - init ( mbox.button_digit[0] - , mbox.button_digit[1] - , mbox.button_digit[2] ); + init(); } //---------------------------------------------------------------------- @@ -83,9 +85,10 @@ FMessageBox::FMessageBox ( const FString& caption , FWidget* parent ) : FDialog{parent} , text{message} + , button_digit{button0, button1, button2} { setTitlebarText(caption); - init(button0, button1, button2); + init(); } //---------------------------------------------------------------------- @@ -111,6 +114,7 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox) if ( mbox.getParentWidget() ) mbox.getParentWidget()->addChild (this); + setTitlebarText (mbox.getTitlebarText()); headline_text = mbox.headline_text; text = mbox.text; text_components = mbox.text_components; @@ -119,11 +123,10 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox) emphasis_color = mbox.emphasis_color; num_buttons = mbox.num_buttons; text_num_lines = mbox.text_num_lines; - - setTitlebarText (mbox.getTitlebarText()); - init ( mbox.button_digit[0] - , mbox.button_digit[1] - , mbox.button_digit[2] ); + button_digit[0] = mbox.button_digit[0]; + button_digit[1] = mbox.button_digit[1]; + button_digit[2] = mbox.button_digit[2]; + init(); return *this; } @@ -149,12 +152,14 @@ void FMessageBox::setText (const FString& txt) { text.setString(txt); 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); - if ( button_digit[2] != 0 ) + if ( button[2] && button_digit[2] != 0 ) button[2]->setY (int(getHeight()) - 4, false); adjustButtons(); @@ -197,30 +202,27 @@ void FMessageBox::cb_processClick (const FWidget*, FDataPtr data) // private methods of FMessageBox //---------------------------------------------------------------------- -void FMessageBox::init (int button0, int button1, int button2) +void FMessageBox::init() { 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 ) - button0 = FMessageBox::Ok; + if ( button_digit[0] == 0 ) + button_digit[0] = FMessageBox::Ok; - if ( button1 == 0 && button2 == 0 ) + if ( button_digit[1] == 0 && button_digit[2] == 0 ) num_buttons = 1; - else if ( button2 == 0 ) + else if ( button_digit[2] == 0 ) num_buttons = 2; else num_buttons = 3; - button_digit[0] = button0; - button_digit[1] = button1; - button_digit[2] = button2; - - allocation (button0, button1, button2); + allocation(); resizeButtons(); adjustButtons(); initCallbacks(); @@ -228,30 +230,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 { 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]->setWidth(1, false); button[0]->setHeight(1, false); button[0]->setFocus(); - if ( button1 > 0 ) + if ( button_digit[1] > 0 ) { 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]->setWidth(0, false); button[1]->setHeight(1, false); } - if ( button2 > 0 ) + if ( button_digit[2] > 0 ) { 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]->setWidth(0, false); button[2]->setHeight(1, false); diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 8278f49d..2581ebe6 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -1501,13 +1501,13 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term 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); } 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); } } @@ -1515,13 +1515,13 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term { 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); } 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); } } @@ -1529,7 +1529,7 @@ inline void FOptiAttr::change_current_color ( const FChar* const& term { fg = vga2ansi(fg); 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); } } diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 8bef544c..88389cfd 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -288,7 +288,7 @@ void FOptiMove::set_column_address (const char 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.duration = capDuration (temp, 1); F_column_address.length = capDurationToLength (F_column_address.duration); @@ -306,7 +306,7 @@ void FOptiMove::set_row_address (const char 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.duration = capDuration (temp, 1); F_row_address.length = capDurationToLength (F_row_address.duration); @@ -324,7 +324,7 @@ void FOptiMove::set_parm_up_cursor (const char 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.duration = capDuration (temp, 1); F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration); @@ -342,7 +342,7 @@ void FOptiMove::set_parm_down_cursor (const char 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.duration = capDuration (temp, 1); F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration); @@ -360,7 +360,7 @@ void FOptiMove::set_parm_left_cursor (const char 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.duration = capDuration (temp, 1); F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration); @@ -378,7 +378,7 @@ void FOptiMove::set_parm_right_cursor (const char 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.duration = capDuration (temp, 1); F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration); @@ -396,7 +396,7 @@ void FOptiMove::set_erase_chars (const char 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.duration = capDuration (temp, 1); F_erase_chars.length = capDurationToLength (F_erase_chars.duration); @@ -414,7 +414,7 @@ void FOptiMove::set_repeat_char (const char 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.duration = capDuration (temp, 1); F_repeat_char.length = capDurationToLength (F_repeat_char.duration); @@ -689,7 +689,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) if ( 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 ); move[BUF_SIZE - 1] = '\0'; } @@ -716,7 +716,7 @@ inline void FOptiMove::downMove ( char move[], int& vtime if ( 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 ); move[BUF_SIZE - 1] = '\0'; } @@ -744,7 +744,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime if ( 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 ); move[BUF_SIZE - 1] = '\0'; } @@ -770,7 +770,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) { // Move to fixed column position1 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 ); hmove[BUF_SIZE - 1] = '\0'; htime = F_column_address.duration; @@ -793,7 +793,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime ) { std::strncpy ( hmove - , FTermcap::encodeParameter(F_parm_right_cursor.cap, num) + , FTermcap::encodeParameter(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0) , BUF_SIZE - 1); hmove[BUF_SIZE - 1] = '\0'; htime = F_parm_right_cursor.duration; @@ -848,7 +848,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime ) { std::strncpy ( hmove - , FTermcap::encodeParameter(F_parm_left_cursor.cap, num) + , FTermcap::encodeParameter(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0) , BUF_SIZE - 1); hmove[BUF_SIZE - 1] = '\0'; htime = F_parm_left_cursor.duration; diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 829b8af9..e99b530a 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -38,8 +38,7 @@ namespace finalcut FProgressbar::FProgressbar(FWidget* parent) : FWidget{parent} { - unsetFocusable(); - setShadow(); + init(); } //---------------------------------------------------------------------- @@ -133,6 +132,13 @@ void FProgressbar::reset() // private methods of FProgressbar +//---------------------------------------------------------------------- +void FProgressbar::init() +{ + unsetFocusable(); + setShadow(); +} + //---------------------------------------------------------------------- void FProgressbar::draw() { diff --git a/src/fradiomenuitem.cpp b/src/fradiomenuitem.cpp index b3be0246..1496b916 100644 --- a/src/fradiomenuitem.cpp +++ b/src/fradiomenuitem.cpp @@ -36,14 +36,14 @@ namespace finalcut FRadioMenuItem::FRadioMenuItem (FWidget* parent) : FMenuItem{parent} { - init (parent); + init(); } //---------------------------------------------------------------------- FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent) : FMenuItem{txt, parent} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -53,10 +53,11 @@ FRadioMenuItem::~FRadioMenuItem() // destructor // private methods of FRadioMenuItem //---------------------------------------------------------------------- -void FRadioMenuItem::init (FWidget* parent) +void FRadioMenuItem::init() { setCheckable(); setRadioButton(); + FWidget* parent = getParentWidget(); if ( ! parent ) return; diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index cbc11031..5b0d722f 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -40,7 +40,7 @@ namespace finalcut FScrollView::FScrollView (FWidget* parent) : FWidget{parent} { - init(parent); + init(); } //---------------------------------------------------------------------- @@ -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->isInstanceOf("FScrollView") ); diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index a2ec6983..a9e17f1b 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -38,7 +38,7 @@ namespace finalcut FStatusKey::FStatusKey(FWidget* parent) : FWidget{parent} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -47,7 +47,7 @@ FStatusKey::FStatusKey (FKey k, const FString& txt, FWidget* parent) , text{txt} , key{k} { - init (parent); + init(); } //---------------------------------------------------------------------- @@ -99,9 +99,10 @@ bool FStatusKey::setMouseFocus(bool enable) // private methods of FStatusKey //---------------------------------------------------------------------- -void FStatusKey::init (FWidget* parent) +void FStatusKey::init() { setGeometry (FPoint{1, 1}, FSize{1, 1}); + FWidget* parent = getParentWidget(); if ( parent && parent->isInstanceOf("FStatusBar") ) { diff --git a/src/fstring.cpp b/src/fstring.cpp index a2e9ffe7..7c3ba53a 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -980,13 +980,7 @@ bool FString::operator == (const FString& s) const //---------------------------------------------------------------------- bool FString::operator != (const FString& s) const { - if ( ! (string || s.string) ) - return false; - - if ( bool(string) != bool(s.string) || length != s.length ) - return true; - - return ( std::wcscmp(string, s.string) != 0 ); + return ! ( *this == s ); } //---------------------------------------------------------------------- diff --git a/src/fterm.cpp b/src/fterm.cpp index 931d2463..c7eb3e32 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -578,6 +578,12 @@ bool FTerm::isNewFont() return data->isNewFont(); } +//---------------------------------------------------------------------- +bool FTerm::isInitialized() +{ + return term_initialized; +} + //---------------------------------------------------------------------- bool FTerm::isCursorHideable() { @@ -1021,9 +1027,9 @@ void FTerm::setPalette (FColor index, int r, int g, int b) const int bb = (b * 1001) / 256; if ( Ic ) - color_str = FTermcap::encodeParameter(Ic, index, rr, gg, bb); + color_str = FTermcap::encodeParameter(Ic, index, rr, gg, bb, 0, 0, 0, 0, 0); else if ( Ip ) - color_str = FTermcap::encodeParameter(Ip, index, 0, 0, 0, rr, gg, bb); + color_str = FTermcap::encodeParameter(Ip, index, 0, 0, 0, rr, gg, bb, 0, 0); if ( color_str ) { @@ -1893,6 +1899,26 @@ inline bool FTerm::hasNoFontSettingOption() return false; } +//---------------------------------------------------------------------- +inline bool FTerm::isDefaultPaletteTheme() +{ + FStringList default_themes + { + "default8ColorPalette", + "default16ColorPalette", + "default16DarkColorPalette" + }; + + auto iter = std::find ( default_themes.begin() + , default_themes.end() + , getColorPaletteTheme()->getClassName() ); + + if ( iter == default_themes.end() ) // No default theme + return false; + + return true; +} + //---------------------------------------------------------------------- void FTerm::redefineColorPalette() { @@ -1904,16 +1930,23 @@ void FTerm::redefineColorPalette() resetColorMap(); saveColorMap(); + if ( getColorPaletteTheme().use_count() > 0 && ! isDefaultPaletteTheme() ) + { + // A user color palette theme is in use + getColorPaletteTheme()->setColorPalette(); + return; + } + if ( getStartOptions().dark_theme ) { - setColorPaletteTheme(&FTerm::setPalette); + setColorPaletteTheme(); } else { if ( getMaxColor() >= 16 ) - setColorPaletteTheme(&FTerm::setPalette); + setColorPaletteTheme(); else // 8 colors - setColorPaletteTheme(&FTerm::setPalette); + setColorPaletteTheme(); } } @@ -2468,7 +2501,7 @@ void FTerm::finish() // Switch to normal escape key mode disableApplicationEscKey(); - finishOSspecifics1(); + finishOSspecifics(); if ( isKdeTerminal() ) setKDECursor(fc::BlockCursor); @@ -2496,7 +2529,7 @@ void FTerm::finish() } //---------------------------------------------------------------------- -void FTerm::finishOSspecifics1() +void FTerm::finishOSspecifics() { #if defined(__linux__) linux->finish(); diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index d90f226c..646044c7 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -247,9 +247,11 @@ bool hasFullWidthSupports() if ( has_fullwidth_support == unknown_fullwidth_support ) { + if ( ! FTerm::isInitialized() ) + return true; // Assume that it is a modern terminal with full-width support + if ( FTerm::isCygwinTerminal() || FTerm::isTeraTerm() - || FTerm::isRxvtTerminal() || FTerm::isFreeBSDTerm() || FTerm::isNetBSDTerm() || FTerm::isOpenBSDTerm() diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index c120e63a..56c6c8d3 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -841,10 +841,10 @@ void FTermXTerminal::enableXTermMouse() fsystem = FTerm::getFSystem(); FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking - CSI "?1000h" // enable x11 mouse tracking - CSI "?1002h" // enable cell motion mouse tracking - CSI "?1015h" // enable urxvt mouse mode - CSI "?1006h"); // enable SGR mouse mode + CSI "?1000;" // enable x11 mouse tracking + "1002;" // enable cell motion mouse tracking + "1015;" // enable urxvt mouse mode + "1006h"); // enable SGR mouse mode std::fflush(stdout); mouse_support = true; } @@ -857,10 +857,10 @@ void FTermXTerminal::disableXTermMouse() if ( ! mouse_support ) return; // The mouse was already deactivated - FTerm::putstring (CSI "?1006l" // disable SGR mouse mode - CSI "?1015l" // disable urxvt mouse mode - CSI "?1002l" // disable cell motion mouse tracking - CSI "?1000l" // disable x11 mouse tracking + FTerm::putstring (CSI "?1006;" // disable SGR mouse mode + "1015;" // disable urxvt mouse mode + "1002;" // disable cell motion mouse tracking + "1000l" // disable x11 mouse tracking CSI "?1001r"); // restore old highlight mouse tracking std::fflush(stdout); mouse_support = false; diff --git a/src/fvterm.cpp b/src/fvterm.cpp index aaf33999..2db393dc 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2502,7 +2502,7 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y if ( le ) appendOutputBuffer (le); else if ( RI ) - appendOutputBuffer (FTermcap::encodeParameter(RI, 1)); + appendOutputBuffer (FTermcap::encodeParameter(RI, 1, 0, 0, 0, 0, 0, 0, 0, 0)); else { skipPaddingCharacter (x, y, prev_char); @@ -2542,7 +2542,7 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y if ( le ) appendOutputBuffer (le); else if ( RI ) - appendOutputBuffer (FTermcap::encodeParameter(RI, 1)); + appendOutputBuffer (FTermcap::encodeParameter(RI, 1, 0, 0, 0, 0, 0, 0, 0, 0)); if ( le || RI ) { @@ -2614,7 +2614,7 @@ FVTerm::exit_state FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y && (ut || normal) ) { appendAttributes (print_char); - appendOutputBuffer (FTermcap::encodeParameter(ec, whitespace)); + appendOutputBuffer (FTermcap::encodeParameter(ec, whitespace, 0, 0, 0, 0, 0, 0, 0, 0)); if ( x + whitespace - 1 < xmax || draw_trailing_ws ) setTermXY (int(x + whitespace), int(y)); @@ -2679,7 +2679,7 @@ FVTerm::exit_state FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) newFontChanges (print_char); charsetChanges (print_char); appendAttributes (print_char); - appendOutputBuffer (FTermcap::encodeParameter(rp, print_char->ch, repetitions)); + appendOutputBuffer (FTermcap::encodeParameter(rp, print_char->ch, repetitions, 0, 0, 0, 0, 0, 0, 0)); term_pos->x_ref() += int(repetitions); x = x + repetitions - 1; } @@ -3062,7 +3062,7 @@ int FVTerm::appendLowerRight (FChar*& screen_char) if ( IC ) { - appendOutputBuffer (FTermcap::encodeParameter(IC, 1)); + appendOutputBuffer (FTermcap::encodeParameter(IC, 1, 0, 0, 0, 0, 0, 0, 0, 0)); appendChar (screen_char); } else if ( im && ei ) diff --git a/src/fwidget.cpp b/src/fwidget.cpp index fdbbcc66..3fc74c42 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1257,6 +1257,12 @@ bool FWidget::isChildPrintArea() const return false; } +//---------------------------------------------------------------------- +bool FWidget::isDesktopInitialized() const +{ + return ( root_widget ) ? root_widget->init_desktop : false; +} + //---------------------------------------------------------------------- void FWidget::setStatusBar (FStatusBar* sbar) { @@ -1774,6 +1780,10 @@ void FWidget::initRootWidget() return; } + // Initialize default widget colors + // (before terminal detection and root_widget is set) + initColorTheme(); + // Root widget basic initialization root_widget = this; show_root_widget = nullptr; @@ -1783,9 +1793,6 @@ void FWidget::initRootWidget() // Determine width and height of the terminal determineDesktopSize(); - - // Initialize default widget colors (before terminal detection) - initColorTheme(); } //---------------------------------------------------------------------- @@ -2057,11 +2064,35 @@ void FWidget::drawChildren() } } +//---------------------------------------------------------------------- +inline bool FWidget::isDefaultTheme() +{ + FStringList default_themes + { + "default8ColorTheme", + "default16ColorTheme", + "default8ColorDarkTheme", + "default16ColorDarkTheme" + }; + + auto iter = std::find ( default_themes.begin() + , default_themes.end() + , getColorTheme()->getClassName() ); + + if ( iter == default_themes.end() ) // No default theme + return false; + + return true; +} + //---------------------------------------------------------------------- void FWidget::initColorTheme() { // Sets the default color theme + if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() ) + return; // A user theme is in use + if ( FStartOptions::getFStartOptions().dark_theme ) { if ( FTerm::getMaxColor() < 16 ) // for 8 color mode @@ -2069,7 +2100,7 @@ void FWidget::initColorTheme() else setColorTheme(); } - else + else // Default theme { if ( FTerm::getMaxColor() < 16 ) // for 8 color mode setColorTheme(); diff --git a/src/fwidget_functions.cpp b/src/fwidget_functions.cpp index d97426d7..a0d1dc70 100644 --- a/src/fwidget_functions.cpp +++ b/src/fwidget_functions.cpp @@ -150,7 +150,7 @@ void drawShadow (FWidget* w) if ( w->flags.trans_shadow ) drawTransparentShadow (w); // transparent shadow - else + else if ( w->flags.shadow ) drawBlockShadow (w); // non-transparent shadow } diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 11a8d648..db0592a4 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -150,7 +150,7 @@ class FApplication : public FWidget typedef std::deque FEventQueue; // Methods - void init (uInt64, uInt64); + void init(); static void setTerminalEncoding (const FString&); static void setLogFile (const FString&); static void cmd_options (const int&, char*[]); diff --git a/src/include/final/fbusyindicator.h b/src/include/final/fbusyindicator.h index 9fb39bf8..761194ad 100644 --- a/src/include/final/fbusyindicator.h +++ b/src/include/final/fbusyindicator.h @@ -96,6 +96,7 @@ class FBusyIndicator : public FToolTip static constexpr std::size_t TIMER = 200; // Methods + void init(); void createIndicatorText(); // Event handler diff --git a/src/include/final/fcheckmenuitem.h b/src/include/final/fcheckmenuitem.h index e7e006ec..e2f795e2 100644 --- a/src/include/final/fcheckmenuitem.h +++ b/src/include/final/fcheckmenuitem.h @@ -82,7 +82,7 @@ class FCheckMenuItem : public FMenuItem private: // Methods - void init (FWidget*); + void init(); void processToggle(); void processClicked() override; }; diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index 282143cf..69be88c6 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -172,7 +172,7 @@ class FMenu : public FWindow, public FMenuList bool isMouseOverMenuBar (const FPoint&); // Methods - void init(FWidget*); + void init(); void initCallbacks(); void calculateDimensions(); void adjustItems(); diff --git a/src/include/final/fmenuitem.h b/src/include/final/fmenuitem.h index b2888e47..7cccde36 100644 --- a/src/include/final/fmenuitem.h +++ b/src/include/final/fmenuitem.h @@ -154,7 +154,7 @@ class FMenuItem : public FWidget FMenuList* getFMenuList (FWidget&); // Methods - void init (FWidget*); + void init(); void updateSuperMenuDimensions(); void processEnable(); void processDisable(); diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index 7ee09d56..b5db8d6c 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -138,8 +138,8 @@ class FMessageBox : public FDialog private: // Methods - void init (int, int, int); - void allocation (int, int, int); + void init(); + void allocation(); void deallocation(); void initCallbacks(); void calculateDimensions(); diff --git a/src/include/final/fprogressbar.h b/src/include/final/fprogressbar.h index b7630ea3..d77b62aa 100644 --- a/src/include/final/fprogressbar.h +++ b/src/include/final/fprogressbar.h @@ -93,6 +93,7 @@ class FProgressbar : public FWidget static constexpr std::size_t NOT_SET = static_cast(-1); // Methods + void init(); void draw() override; void drawProgressLabel(); void drawProgressBar(); diff --git a/src/include/final/fradiomenuitem.h b/src/include/final/fradiomenuitem.h index ad14547c..d98259cc 100644 --- a/src/include/final/fradiomenuitem.h +++ b/src/include/final/fradiomenuitem.h @@ -82,7 +82,7 @@ class FRadioMenuItem : public FMenuItem private: // Methods - void init (FWidget*); + void init(); void processToggle(); void processClicked() override; }; diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index 83cef868..1cca1927 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -160,7 +160,7 @@ class FScrollView : public FWidget const FPoint getViewportCursorPos(); // Methods - void init (const FWidget*); + void init(); void mapKeyFunctions(); void calculateScrollbarPos(); template diff --git a/src/include/final/fstatusbar.h b/src/include/final/fstatusbar.h index f9b3f961..db45f601 100644 --- a/src/include/final/fstatusbar.h +++ b/src/include/final/fstatusbar.h @@ -109,7 +109,7 @@ class FStatusKey : public FWidget private: // Methods - void init (FWidget*); + void init(); void processActivate(); FStatusBar* getConnectedStatusbar() const; void setConnectedStatusbar (FStatusBar*); diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index d35e8b7e..8874abd8 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -241,6 +241,7 @@ class FTerm final static bool isScreenTerm(); static bool isTmuxTerm(); static bool isNewFont(); + static bool isInitialized(); static bool isCursorHideable(); static bool hasChangedTermSize(); static bool hasShadowCharacter(); @@ -277,7 +278,7 @@ class FTerm final static void resetColorMap(); static void setPalette (FColor, int, int, int); template - static void setColorPaletteTheme (const FSetPalette&); + static void setColorPaletteTheme (const FSetPalette& = &FTerm::setPalette); static void setBeep (int, int); static void resetBeep(); static void beep(); @@ -332,6 +333,7 @@ class FTerm final static void init_tab_quirks(); static void init_captureFontAndTitle(); static bool hasNoFontSettingOption(); + static bool isDefaultPaletteTheme(); static void redefineColorPalette(); static void restoreColorPalette(); static void setInsertCursorStyle(); @@ -355,7 +357,7 @@ class FTerm final void initTermspecifics(); void initBaudRate(); void finish(); - void finishOSspecifics1(); + void finishOSspecifics(); void finish_encoding(); void destroyColorPaletteTheme(); static void printExitMessage(); diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index f78273bc..d9af1d0a 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -368,6 +368,7 @@ class FWidget : public FVTerm, public FObject // Inquiry bool isChildPrintArea() const; + bool isDesktopInitialized() const; // Mutators virtual void setStatusBar (FStatusBar*); @@ -467,6 +468,7 @@ class FWidget : public FVTerm, public FObject virtual void draw(); void drawWindows(); void drawChildren(); + static bool isDefaultTheme(); static void initColorTheme(); void destroyColorTheme(); void setStatusbarText (bool); @@ -595,6 +597,7 @@ struct FWidget::FCallbackData // non-member function forward declarations // implemented in fwidget_functions.cpp //---------------------------------------------------------------------- +void initWidget (FWidget*); void detectTermSize(); bool isFocusNextKey (const FKey); bool isFocusPrevKey (const FKey); diff --git a/src/include/final/fwidgetcolors.h b/src/include/final/fwidgetcolors.h index 425cffa9..b839aecf 100644 --- a/src/include/final/fwidgetcolors.h +++ b/src/include/final/fwidgetcolors.h @@ -54,6 +54,7 @@ class FWidgetColors virtual ~FWidgetColors(); // Method + virtual const FString getClassName() const; virtual void setColorTheme() = 0; // Data members @@ -145,6 +146,11 @@ class FWidgetColors FColor progressbar_bg{fc::Default}; }; +// FWidgetColors inline functions +//---------------------------------------------------------------------- +inline const FString FWidgetColors::getClassName() const +{ return "FWidgetColors"; } + /* Inheritance diagram * ═══════════════════ @@ -173,9 +179,15 @@ class default8ColorTheme final : public FWidgetColors ~default8ColorTheme() override; // Method + const FString getClassName() const override; void setColorTheme() override; }; +// default8ColorTheme inline functions +//---------------------------------------------------------------------- +inline const FString default8ColorTheme::getClassName() const +{ return "default8ColorTheme"; } + /* Inheritance diagram * ═══════════════════ @@ -204,9 +216,15 @@ class default16ColorTheme final : public FWidgetColors ~default16ColorTheme() override; // Method + const FString getClassName() const override; void setColorTheme() override; }; +// default16ColorTheme inline functions +//---------------------------------------------------------------------- +inline const FString default16ColorTheme::getClassName() const +{ return "default16ColorTheme"; } + /* Inheritance diagram * ═══════════════════ @@ -235,9 +253,15 @@ class default8ColorDarkTheme final : public FWidgetColors ~default8ColorDarkTheme() override; // Method + const FString getClassName() const override; void setColorTheme() override; }; +// default8ColorDarkTheme inline functions +//---------------------------------------------------------------------- +inline const FString default8ColorDarkTheme::getClassName() const +{ return "default8ColorDarkTheme"; } + /* Inheritance diagram * ═══════════════════ @@ -266,9 +290,15 @@ class default16ColorDarkTheme final : public FWidgetColors ~default16ColorDarkTheme() override; // Method + const FString getClassName() const override; void setColorTheme() override; }; +// default16ColorDarkTheme inline functions +//---------------------------------------------------------------------- +inline const FString default16ColorDarkTheme::getClassName() const +{ return "default16ColorDarkTheme"; } + } // namespace finalcut #endif // FWIDGETCOLORS_H diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index 20254db6..4eb56e84 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -310,7 +310,7 @@ void FTermDetectionTest::rxvtTest() CPPUNIT_ASSERT ( detect.canDisplay256Colors() ); CPPUNIT_ASSERT ( detect.hasTerminalDetection() ); CPPUNIT_ASSERT ( ! detect.hasSetCursorStyleSupport() ); - CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "rxvt-cygwin-native") ; + CPPUNIT_ASSERT_CSTRING ( detect.getTermType(), "rxvt-16color") ; printConEmuDebug(); closeConEmuStdStreams();