diff --git a/.bettercodehub.yml b/.bettercodehub.yml index 780431f5..80c34c67 100644 --- a/.bettercodehub.yml +++ b/.bettercodehub.yml @@ -1,11 +1,15 @@ exclude: -- /fonts/.* -- /scripts/.* -- /doc/.* -- /build.sh -- /ltmain.sh -component_depth: 1 + - /debian/.* + - /doc/.* + - /examples/.* + - /fonts/.* + - /icon/.* + - /logo/.* + - /m4/.* + - /scripts/.* + - /build.sh + - /ltmain.sh +component_depth: 3 languages: - cpp -- script diff --git a/.gitignore b/.gitignore index 1be54131..c1e67a39 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ examples/windows examples/term-attributes examples/transparent examples/input-dialog +examples/fullwidth-character +examples/7segment examples/choice examples/listbox examples/listview diff --git a/.travis.yml b/.travis.yml index 97176338..216c09b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ addons: - autoconf - autoconf-archive - libtool + - pkg-config - libglib2.0-dev - libncurses5-dev - gpm @@ -21,6 +22,7 @@ addons: homebrew: packages: - autoconf-archive + update: true env: global: @@ -52,7 +54,7 @@ matrix: name: gansm/finalcut description: Build submitted via Travis CI notification_email: guru.mail@muenster.de - build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG' --with-unit-test && make clean" + build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG -DUNIT_TEST' --with-unit-test && make clean" build_command: "make V=1 -j10" branch_pattern: master before_install: @@ -60,15 +62,18 @@ matrix: - uname -a - whoami - sudo apt-get install gpm libgpm-dev libcppunit-dev autoconf-archive + # Work around broken certificate of scan.coverity.com + - sudo curl -s -L https://entrust.com/root-certificates/entrust_l1k.cer -o /usr/local/share/ca-certificates/entrust_l1k.crt + - sudo update-ca-certificates script: - autoreconf -v --install --force - - ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test + - ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test - make V=1 -j10 - make check - cat test/*.log # - # Coveralls + # Coveralls + Codecov # - os: linux env: @@ -77,10 +82,12 @@ matrix: - lsb_release -a - uname -a - pip install --user cpp-coveralls + - sudo pip install codecov script: - ./build.sh coverage after_success: - coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples + - bash <(curl -s https://codecov.io/bash) # # macOS diff --git a/ChangeLog b/ChangeLog index f90263c0..857ac33f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,112 @@ +2019-09-28 Markus Gans + * Support for displaying full-width characters (2 columns wide) + on the terminal. This is particularly important for the correct + display of CJK characters + +2019-09-16 Markus Gans + * Improve FStartOptions implementation + +2019-09-08 Markus Gans + * Remove the lines of the #pragma pack() directive from the code + because they caused a misaligned address + +2019-09-06 Markus Gans + * Outsourcing the initialization data to a separate struct + +2019-09-04 Markus Gans + * The Cygwin and Linux console do not use cp437 character encoding + by default anymore + +2019-09-01 Markus Gans + * Removing public + protected data members from classes + +2019-08-25 Markus Gans + * More use of direct initializations + +2019-08-18 Markus Gans + * Solved problem detecting terminal size on quick changes + * Update VTerm information only in case of changes + * Fixes print() << FPoint() behavior in FScrollView + +2019-08-11 Markus Gans + * FRect has now got a scaleBy() method + * Convert drawBorder() to a non-member function using FRect + * Converts getHotkeyPos() for sharing into a non-member function + +2019-08-10 Markus Gans + * Pitch and duration of system speaker can now be changed + on OpenBSD + +2019-08-07 Markus Gans + * Fixes the Cygwin build + +2019-08-04 Markus Gans + * Reduce the number of interface parameters + +2019-07-31 Markus Gans + * Unit test for the move assignment operator and move constructor + in FPoint, FSize and FRect + +2019-07-28 Markus Gans + * FreeBSD can now change the frequency and duration + of the pc speaker signal + * Added a unit test for the FTermFreeBSD class to test + the FreeBSD console + +2019-07-21 Markus Gans + * Reduce include entries in the header files + +2019-07-14 Markus Gans + * Reduces the use of raw loops + * Add a unit test for FTermOpenBSD to test the OpenBSD + and NetBSD console + +2019-06-30 Markus Gans + * Expanding the unit test for FTermLinux + * Update the cp437 unicode map + * Reducing the special cases for Solaris + +2019-06-19 Markus Gans + * Add a unit test for FTermLinux with a Linux console emulation + and a dedicated FSystem test instance + +2019-06-12 Markus Gans + * Fixes problem with scroll bar view after first draw + +2019-06-02 Markus Gans + * Avoid drawing the scroll bars if the widget is non-visible + +2019-05-27 Markus Gans + * Use the Singleton design pattern to get a single object instance + via FTerm + +2019-05-26 Marek Habersack + * Fix a segfault when processing input to empty FListView + +2019-05-17 Markus Gans + * Move system calls to the new class FSystem + +2019-04-27 Markus Gans + * Add the reserve() method to FListBox to increase the capacity + of the list + * Use shrink_to_fit() to save memory space + +2019-03-24 Markus Gans + * Add a "scroll view" chapter to the first steps document + +2019-02-28 Markus Gans + * Add an lambda expression callback example to the first steps document + +2019-02-24 Markus Gans + * FLineEdit now has the ability to define a character input filter + via regular expression (regex) + * Now FLineEdit can define a maximum character length for the input + * The cursor position can now be set directly in FLineEdit + * Added the 7-segment example to demonstrate the use of FTermBuffer + and FLineEdit input filters + 2019-02-07 Markus Gans - * Add a "dynamic layout" Chapter into the first steps document + * Add a "dynamic layout" chapter into the first steps document 2019-01-30 Markus Gans * Printing an FColorPair object can change the foreground and @@ -91,7 +198,7 @@ the switch statement with a vector of lambda expressions 2018-12-09 Markus Gans - * Better handling of the scrollbar maximum + * Better handling of the scroll bar maximum * Deactivate copy constructor and assignment operator with "= delete" * Use nullptr instead of 0 to initialize a pointer values @@ -107,7 +214,7 @@ * Fix compile in optimization level 2 for newer gcc 2018-11-27 Markus Gans - * Correct vertical scrollbar position after sorting in FListView + * Correct vertical scroll bar position after sorting in FListView 2018-11-25 Markus Gans * Version 0.5.0 diff --git a/README.md b/README.md index 69fa5553..b9b1b04f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ ![FINAL CUT](logo/svg/finalcut-logo.svg) ============================================ -### Building and code analysis +# 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 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 *Latest release:*
     [![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases)
*License:*
@@ -9,18 +14,13 @@ *Travis CI:*
     [![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut)
*Coverity Scan:*
-     [![Coverity Scan Status](https://scan.coverity.com/projects/6508/badge.svg)](https://scan.coverity.com/projects/6508)
+     [![Coverity Scan Status](https://img.shields.io/coverity/scan/6508.svg)](https://scan.coverity.com/projects/6508)
*LGTM:*
     [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/gansm/finalcut.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/gansm/finalcut/context:cpp)
*Class Reference:*
     [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html) -### Description -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 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. - -### Installation +## Installation ```bash > git clone git://github.com/gansm/finalcut.git > cd finalcut @@ -30,7 +30,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla > su -c "make install" ``` -### Supported platforms +## Supported platforms * Linux * FreeBSD * NetBSD @@ -39,13 +39,12 @@ The structure of the Qt framework was originally the inspiration for the C++ cla * Cygwin * Solaris -### First steps +## First steps +Read here [how to use the library](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit) -[How to use the library](doc/first-steps.md#first-steps-with-the-final-cut-widget-toolkit) +## Some screenshots -### Screenshots - -The FFileDialog widget: +The FFileDialog widget with incremental file name search: ![FFileDialog](doc/fileopen-dialog.png) @@ -152,47 +151,53 @@ Class digramm 1┌──────────────┐ ┌-----------┤ FTermFreeBSD │ : └──────────────┘ - : 1┌──────────────┐ ┌───────────┐ - ┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ - : └──────────────┘ │ └───────────┘ + : 1┌──────────────┐ + ┌-----------┤ FTermOpenBSD │ + : └──────────────┘ + : 1┌────────────────┐ ┌───────────┐ + ┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │ + : └────────────────┘ │ └───────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ + ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │ : └────────────────┘ │ └─────────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ - : └────────────────┘ │ └─────────────┘ - : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │ + ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │ : └────────────────┘ │ └─────────────┘ : 1┌──────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ + ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │ : └──────────┘ │ └─────────────┘ - : 1┌──────────┐ │ ┌──────────────┐ - ┌-----------┤ FTermios │ ├────┤ FResizeEvent │ - : └──────────┘ │ └──────────────┘ - : 1┌───────────────┐ │ ┌────────────┐ - ┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ - : └───────────────┘ │ └────────────┘ + : 1┌──────────┐ │ ┌─────────────┐ + ┌-----------┤ FTermios │ ├────┤ FAccelEvent │ + : └──────────┘ │ └─────────────┘ + : 1┌───────────────┐ │ ┌──────────────┐ + ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │ + : └───────────────┘ │ └──────────────┘ : 1┌───────────┐ │ ┌────────────┐ - ┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ + ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │ + : └───────────┘ │ └────────────┘ + : 1┌───────────┐ │ ┌────────────┐ + ┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │ : └───────────┘ │ └────────────┘ : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ + ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │ : └───────────┘ │ └─────────────┘ - : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ - : └───────────┘ │ └─────────────┘ - : 1┌───────────────┐ │ - ┌-----------┤ FMouseControl │ │ ┌──────────────┐ - : └───────────────┘ │ ┌────┤ FApplication │ - : *┌─────────┐ │ │ └──────────────┘ - : ┌--------┤ FString │ │ │ ┌─────────┐ - : : └─────────┘ │ ├────┤ FButton │ - : : *┌────────┐ │ │ └─────────┘ - : ┌--------┤ FPoint │ │ │ ┌────────┐ - : : └────────┘ │ ├────┤ FLabel │ + : 1┌───────────────┐ │ ┌─────────────┐ + ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ + : └───────────────┘ │ └─────────────┘ + : 1┌─────────┐ │ + ┌-----------┤ FSystem │ │ + : └─────────┘ │ + : *┌─────────┐ │ + : ┌--------┤ FString │ │ ┌──────────────┐ + : : └─────────┘ │ ┌────┤ FApplication │ + : : *┌────────┐ │ │ └──────────────┘ + : ┌--------┤ FPoint │ │ │ ┌─────────┐ + : : └────────┘ │ ├────┤ FButton │ + : : *┌───────┐ │ │ └─────────┘ + : ┌--------┤ FRect │ │ │ ┌────────┐ + : : └───────┘ │ ├────┤ FLabel │ : : *┌───────┐ │ │ └────────┘ - : ┌--------┤ FRect │ │ │ ┌───────────┐ + : ┌--------┤ FSize │ │ │ ┌───────────┐ : : └───────┘ │ ├────┤ FLineEdit │ :1 :1 │ │ └───────────┘ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ diff --git a/build.sh b/build.sh index 9918a182..6a6d69fd 100755 --- a/build.sh +++ b/build.sh @@ -35,7 +35,7 @@ then autoreconf --install --force else echo "Build failed, please install autoconf first" - exit -1 + exit 255 fi fi fi @@ -46,7 +46,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O2" # "-O3 -fno-rtti" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -54,15 +54,15 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; "--fulldebug"|"fulldebug") - if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args" + if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args -Wno-format-nonliteral" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -70,7 +70,7 @@ case "$1" in if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -pg -O0 -DDEBUG -W -Wall -pedantic" then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -78,23 +78,23 @@ case "$1" in if ! ./configure --prefix="$PREFIX" --with-profiler then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; "--unit-test"|"unit-test") - if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test + if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; "--coverage"|"coverage") - if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG" --with-unit-test --with-gcov + if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test --with-gcov then echo "${RED}Configure failed!${NORMAL}" 1>&2 - exit -1 + exit 255 fi ;; @@ -139,6 +139,7 @@ if [ "$1" = "--unit-test" ] \ || [ "$1" = "--coverage" ] \ || [ "$1" = "coverage" ] then + rm test/*.log 2>/dev/null cd test && make check-TESTS cat ./*.log 2>/dev/null cd .. || exit diff --git a/debian/libfinal-dev.docs b/debian/libfinal-dev.docs index 3cd9709d..9a1eb31e 100644 --- a/debian/libfinal-dev.docs +++ b/debian/libfinal-dev.docs @@ -1,8 +1,20 @@ +AUTHORS +COPYING +COPYING.LESSER +ChangeLog +README.md doc/calendar-draft.png +doc/calculator.png doc/class-diagram.txt +doc/class_template.cpp +doc/class_template.h doc/console_codes-manual.sh doc/console_ioctl-manual.sh +doc/faq.md doc/fileopen-dialog.png +doc/first-steps.md +doc/framebuffer.txt +doc/Mandelbrot.png doc/ncurses.supp doc/newfont1.png doc/newfont2.png @@ -13,6 +25,8 @@ doc/terminfo-capabilities.sh doc/terminfo-manual.sh doc/textview.png doc/TODO +doc/vga.txt doc/vt100_line_drawing_graphics.png doc/virtual-terminal.txt +doc/xterm.txt doc/xgraphics diff --git a/doc/Makefile.am b/doc/Makefile.am index 90b9f8dd..2eebc1d2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -6,10 +6,17 @@ docdir = ${datadir}/doc/${PACKAGE} EXTRA_DIST = \ calendar-draft.png \ + calculator.png \ class-diagram.txt \ + class_template.cpp \ + class_template.h \ console_codes-manual.sh \ console_ioctl-manual.sh \ + faq.md \ fileopen-dialog.png \ + first-steps.md \ + framebuffer.txt \ + Mandelbrot.png \ ncurses.supp \ newfont1.png \ newfont2.png \ @@ -20,16 +27,25 @@ EXTRA_DIST = \ terminfo-manual.sh \ textview.png \ TODO \ + vga.txt \ vt100_line_drawing_graphics.png \ virtual-terminal.txt \ + xterm.txt \ xgraphics doc_DATA = \ calendar-draft.png \ + calculator.png \ class-diagram.txt \ + class_template.cpp \ + class_template.h \ console_codes-manual.sh \ console_ioctl-manual.sh \ + faq.md \ fileopen-dialog.png \ + first-steps.md \ + framebuffer.txt \ + Mandelbrot.png \ ncurses.supp \ newfont1.png \ newfont2.png \ @@ -40,6 +56,8 @@ doc_DATA = \ terminfo-manual.sh \ textview.png \ TODO \ + vga.txt \ vt100_line_drawing_graphics.png \ virtual-terminal.txt \ + xterm.txt \ xgraphics diff --git a/doc/build_openbsd.txt b/doc/build_openbsd.txt new file mode 100644 index 00000000..2bd180b0 --- /dev/null +++ b/doc/build_openbsd.txt @@ -0,0 +1,24 @@ +Build FINAL CUT with the clang c++ compiler +------------------------------------------- +openbsd# CXX=clang++ ./build.sh + +Build FINAL CUT with eg++ +------------------------- +openbsd# CXX=eg++ ./build.sh + +Install egcc on OpenBSD +----------------------- +openbsd# pkg_add g++ +quirks-3.124 signed on 2019-04-15T12:10:16Z +Ambiguous: choose package for g++ +a 0: + 1: g++-4.9.4p18 + 2: g++-8.3.0 +Your choice: 2 +g++-8.3.0:gcc-libs-8.3.0: ok +g++-8.3.0:gmp-6.1.2p3: ok +g++-8.3.0:mpfr-3.1.5.2p0: ok +g++-8.3.0:libmpc-0.9p2: ok +g++-8.3.0:gcc-8.3.0: ok +g++-8.3.0: ok + diff --git a/doc/build_solaris.txt b/doc/build_solaris.txt new file mode 100644 index 00000000..ec912bd8 --- /dev/null +++ b/doc/build_solaris.txt @@ -0,0 +1,12 @@ +Install gcc5g++ on Solaris +https://www.opencsw.org/packages/gcc5g++/ + +pkgadd -d http://get.opencsw.org/now +/opt/csw/bin/pkgutil -U +/opt/csw/bin/pkgutil -y -i gcc5g++ +/usr/sbin/pkgchk -L CSWgcc5g++ # list files + + + +PATH=/opt/csw/bin:$PATH + diff --git a/doc/class-diagram.txt b/doc/class-diagram.txt index 200f4ace..5157f210 100644 --- a/doc/class-diagram.txt +++ b/doc/class-diagram.txt @@ -4,47 +4,53 @@ 1┌──────────────┐ ┌-----------┤ FTermFreeBSD │ : └──────────────┘ - : 1┌──────────────┐ ┌───────────┐ - ┌-----------┤ FTermOpenBSD │ ┌────┤ FKeyEvent │ - : └──────────────┘ │ └───────────┘ + : 1┌──────────────┐ + ┌-----------┤ FTermOpenBSD │ + : └──────────────┘ + : 1┌────────────────┐ ┌───────────┐ + ┌-----------┤ FTermDetection │ ┌────┤ FKeyEvent │ + : └────────────────┘ │ └───────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermDetection │ ├────┤ FMouseEvent │ + ┌-----------┤ FTermcapQuirks │ ├────┤ FMouseEvent │ : └────────────────┘ │ └─────────────┘ : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcapQuirks │ ├────┤ FWheelEvent │ - : └────────────────┘ │ └─────────────┘ - : 1┌────────────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermXTerminal │ ├────┤ FFocusEvent │ + ┌-----------┤ FTermXTerminal │ ├────┤ FWheelEvent │ : └────────────────┘ │ └─────────────┘ : 1┌──────────┐ │ ┌─────────────┐ - ┌-----------┤ FTermcap │ ├────┤ FAccelEvent │ + ┌-----------┤ FTermcap │ ├────┤ FFocusEvent │ : └──────────┘ │ └─────────────┘ - : 1┌──────────┐ │ ┌──────────────┐ - ┌-----------┤ FTermios │ ├────┤ FResizeEvent │ - : └──────────┘ │ └──────────────┘ - : 1┌───────────────┐ │ ┌────────────┐ - ┌-----------┤ FColorPalette │ ├────┤ FShowEvent │ - : └───────────────┘ │ └────────────┘ + : 1┌──────────┐ │ ┌─────────────┐ + ┌-----------┤ FTermios │ ├────┤ FAccelEvent │ + : └──────────┘ │ └─────────────┘ + : 1┌───────────────┐ │ ┌──────────────┐ + ┌-----------┤ FColorPalette │ ├────┤ FResizeEvent │ + : └───────────────┘ │ └──────────────┘ : 1┌───────────┐ │ ┌────────────┐ - ┌-----------┤ FOptiMove │ ├────┤ FHideEvent │ + ┌-----------┤ FOptiMove │ ├────┤ FShowEvent │ + : └───────────┘ │ └────────────┘ + : 1┌───────────┐ │ ┌────────────┐ + ┌-----------┤ FOptiAttr │ ├────┤ FHideEvent │ : └───────────┘ │ └────────────┘ : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FOptiAttr │ ├────┤ FCloseEvent │ + ┌-----------┤ FKeyboard │ ├────┤ FCloseEvent │ : └───────────┘ │ └─────────────┘ - : 1┌───────────┐ │ ┌─────────────┐ - ┌-----------┤ FKeyboard │ ├────┤ FTimerEvent │ - : └───────────┘ │ └─────────────┘ - : 1┌───────────────┐ │ - ┌-----------┤ FMouseControl │ │ ┌──────────────┐ - : └───────────────┘ │ ┌────┤ FApplication │ - : *┌─────────┐ │ │ └──────────────┘ - : ┌--------┤ FString │ │ │ ┌─────────┐ - : : └─────────┘ │ ├────┤ FButton │ - : : *┌────────┐ │ │ └─────────┘ - : ┌--------┤ FPoint │ │ │ ┌────────┐ - : : └────────┘ │ ├────┤ FLabel │ + : 1┌───────────────┐ │ ┌─────────────┐ + ┌-----------┤ FMouseControl │ ├────┤ FTimerEvent │ + : └───────────────┘ │ └─────────────┘ + : 1┌─────────┐ │ + ┌-----------┤ FSystem │ │ + : └─────────┘ │ + : *┌─────────┐ │ + : ┌--------┤ FString │ │ ┌──────────────┐ + : : └─────────┘ │ ┌────┤ FApplication │ + : : *┌────────┐ │ │ └──────────────┘ + : ┌--------┤ FPoint │ │ │ ┌─────────┐ + : : └────────┘ │ ├────┤ FButton │ + : : *┌───────┐ │ │ └─────────┘ + : ┌--------┤ FRect │ │ │ ┌────────┐ + : : └───────┘ │ ├────┤ FLabel │ : : *┌───────┐ │ │ └────────┘ - : ┌--------┤ FRect │ │ │ ┌───────────┐ + : ┌--------┤ FSize │ │ │ ┌───────────┐ : : └───────┘ │ ├────┤ FLineEdit │ :1 :1 │ │ └───────────┘ ┌─┴──┴──┐ │ │ ┌──────────────┐ ┌──────────────┐ @@ -100,4 +106,3 @@ └──────────┘ │ ┌────────────────┐* : └──┤ FRadioMenuItem ├---┘ └────────────────┘ - diff --git a/doc/class_template.h b/doc/class_template.h index 980c57c3..05cbafed 100644 --- a/doc/class_template.h +++ b/doc/class_template.h @@ -44,9 +44,6 @@ namespace finalcut // class FClassName //---------------------------------------------------------------------- -#pragma pack(push) -#pragma pack(1) - class FClassName { public: @@ -82,7 +79,7 @@ class FClassName // Callback methods - // Data Members + // Data members protected: // Typedefs and Enumerations @@ -99,7 +96,7 @@ class FClassName // Callback methods - // Data Members + // Data members private: // Typedefs and Enumerations @@ -116,12 +113,12 @@ class FClassName // Callback methods - // Data Members + // Data members // Friend class }; -#pragma pack(pop) + // FClassName inline functions //---------------------------------------------------------------------- diff --git a/doc/first-steps.md b/doc/first-steps.md index 457d83a3..0f33cd67 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -13,9 +13,11 @@ Table of Contents - [Signals and Callbacks](#signals-and-callbacks) - [Default signals](#the-final-cut-widgets-emit-the-following-default-signals) - [Callback function](#example-of-a-callback-function) +- [Callback lambda expression](#example-of-an-lambda-expression-callback) - [Callback method](#example-of-a-callback-function) - [Custom signals](#send-custom-signals) - [Dynamic layout](#dynamic-layout) +- [Scroll view](#scroll-view) @@ -25,7 +27,7 @@ How to use the library At the beginning of this introduction to the Final Cut we will start with a small example. -The following example creates an empty 30×10 character dialog. +The following example creates an empty 30??10 character dialog. **File:** *dialog.cpp* ```cpp @@ -288,7 +290,7 @@ class dialogWidget : public FDialog } private: - virtual void onTimer (FTimerEvent* ev) override + void onTimer (FTimerEvent* ev) override { if ( id == ev->getTimerId() && n < 9999999999 ) { @@ -479,6 +481,64 @@ g++ -O2 -lfinal callback-function.cpp -o callback-function ```   +### Example of an lambda expression callback: ### + +**File:** *callback-lambda.cpp* + +```cpp +#include + +using namespace finalcut; + +int main (int argc, char* argv[]) +{ + FApplication app(argc, argv); + FDialog dialog(&app); + dialog.setText ("Lambda expression as callback"); + dialog.setGeometry (FRect(25, 5, 45, 9)); + FButton button ("&bottom", &dialog); + button.setGeometry (FPoint(15, 5), FSize(14, 1)); + + // Connect the button signal "clicked" with the lambda expression + button.addCallback + ( + "clicked", + [] (FWidget* w, FDataPtr d) + { + FButton& button = *(static_cast(w)); + + if ( button.getY() != 2 ) + { + button.setPos (FPoint(15, 2)); + button.setText("&top"); + } + else + { + button.setPos (FPoint(15, 5)); + button.setText("&bottom"); + } + + static_cast(d)->redraw(); + }, + &dialog + ); + + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} +``` +*(Note: You can close the dialog with the mouse, +Shift+F10 or Ctrl+^)* + + +After entering the source code in *callback-lambda.cpp* you can compile +the above program with gcc: +```cpp +g++ -O2 -lfinal -std=c++11 callback-lambda.cpp -o callback-lambda +``` +  + ### Example of a callback method: ### **File:** *callback-method.cpp* @@ -639,12 +699,12 @@ class dialogWidget : public FDialog void setTemperature() { label.clear(); - label << t << "°C"; + label << t << "??C"; label.redraw(); } int t = 20; - FLabel label{FString() << t << "°C", this}; + FLabel label{FString() << t << "??C", this}; FButton plus {"&+", this}; FButton minus {"&-", this}; }; @@ -702,8 +762,8 @@ class dialogWidget : public FDialog { setText ("Dialog"); setResizeable(); - btn.setGeometry (FPoint(1, 1), FSize(12, 1), false); - line.setGeometry (FPoint(2, 3), FSize(12, 1), false); + button.setGeometry (FPoint(1, 1), FSize(12, 1), false); + input.setGeometry (FPoint(2, 3), FSize(12, 1), false); // Set dialog geometry and calling adjustSize() setGeometry (FPoint(25, 5), FSize(40, 12)); setMinimumSize (FSize(25, 9)); @@ -727,15 +787,15 @@ class dialogWidget : public FDialog void adjustWidgets() { - auto bx = int(getWidth() - btn.getWidth() - 3); + auto bx = int(getWidth() - button.getWidth() - 3); auto by = int(getHeight() - 4); - btn.setPos (FPoint(bx, by), false); - line.setWidth (getWidth() - 4); + button.setPos (FPoint(bx, by), false); + input.setWidth (getWidth() - 4); auto ly = int(getHeight() / 2) - 1; - line.setY (ly, false); + input.setY (ly, false); } - virtual void adjustSize() override + void adjustSize() override { // Calling super class method adjustSize() FDialog::adjustSize(); @@ -743,14 +803,14 @@ class dialogWidget : public FDialog centerDialog(); } - virtual void setSize (const FSize& size, bool) override + void setSize (const FSize& size, bool) override { // Calling super class methods setSize() + adjustSize() FDialog::setSize (size, false); FDialog::adjustSize(); } - virtual void draw() override + void draw() override { adjustWidgets(); // Adjust widgets before drawing @@ -764,8 +824,8 @@ class dialogWidget : public FDialog << "top"; } - FLineEdit line{"Middle", this}; - FButton btn{"&Bottom", this}; + FLineEdit input{"Middle", this}; + FButton button{"&Bottom", this}; }; int main (int argc, char* argv[]) @@ -787,3 +847,123 @@ the above program with gcc: g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment ``` + +Scroll view +----------- + +The scroll view of the `FScrollView` class allows users to view content +that is larger than the visible area. The `FScrollView` widget displays +the horizontal and vertical scroll bar by default, only if the content size +requires it. You can controll this behavior by the two methods +`setHorizontalScrollBarMode()` and `setVerticalScrollBarMode()`. + +```cpp +setHorizontalScrollBarMode (fc::scrollBarMode); +setVerticalScrollBarMode (fc::scrollBarMode); +``` + +You pass the scroll bar visibility mode as a value of the enum type +`fc::scrollBarMode`. + +```cpp +enum scrollBarMode +{ + Auto = 0, // Shows a scroll bar when area is larger than viewport + Hidden = 1, // Never shows a scroll bar + Scroll = 2 // Always shows a scroll bar +}; +``` + +You can add widgets to an `FScrollView` object as child objects and place +them (with a widget positioning method) on the scrollable area. If a client +widget gets the focus, it automatically scrolls the viewport to the focused +widget. You can use the methods `scrollTo()`, `scrollToX()`, `scrollToY()` +and `scrollBy()` to set the scroll position of the viewport directly. + +The `FButtonGroup` widget uses `FScrollView` to display more buttons +in the frame than the height allows. + +**File:** *scrollview.cpp* +```cpp +#include +#include + +using namespace finalcut; + +class dialogWidget : public FDialog +{ + public: + explicit dialogWidget (FWidget* parent = nullptr) + : FDialog(parent) + { + setText ("Dialog"); + setGeometry (FPoint(28, 2), FSize(24, 21)); + scrollview.setGeometry(FPoint(1, 1), FSize(22, 11)); + scrollview.setScrollSize(FSize(60, 27)); + setColor (wc.label_inactive_fg, wc.dialog_bg); + scrollview.clearArea(); + FColorPair red (fc::LightRed, wc.dialog_bg); + FColorPair black (fc::Black, wc.dialog_bg); + FColorPair cyan (fc::Cyan, wc.dialog_bg); + + static std::vector d + { + {"NW", FPoint(3, 13), FPoint(1, 1), black}, + {"N", FPoint(10, 13), FPoint(21, 1), red}, + {"NE", FPoint(17, 13), FPoint(41, 1), black}, + {"W", FPoint(3, 15), FPoint(1, 10), black}, + {"*", FPoint(10, 15), FPoint(21, 10), black}, + {"E", FPoint(17, 15), FPoint(41, 10), black}, + {"SW", FPoint(3, 17), FPoint(1, 19), black}, + {"S", FPoint(10, 17), FPoint(21, 19), cyan}, + {"SE", FPoint(17, 17), FPoint(41, 19), black} + }; + + for (auto&& b : d) + { + scrollview.print() << std::get<2>(b) + FPoint(10, 5) + << std::get<3>(b) << std::get<0>(b); + auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview); + edit->setGeometry(std::get<2>(b) + FPoint(1, 1), FSize(17, 1)); + auto btn = new FButton(std::get<0>(b), this); + btn->setGeometry(std::get<1>(b), FSize(4, 1)); + btn->unsetShadow(); + btn->addCallback + ( + "clicked", + F_METHOD_CALLBACK (this, &dialogWidget::cb_button), + static_cast(&std::get<2>(b)) + ); + }; + } + + private: + typedef std::tuple direction; + + void cb_button (FWidget*, FDataPtr data) + { + FPoint* p = static_cast(data); + scrollview.scrollTo(*p); + } + + FScrollView scrollview{this}; +}; + +int main (int argc, char* argv[]) +{ + FApplication app(argc, argv); + dialogWidget dialog(&app); + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} +``` +*(Note: You can close the window with the mouse, +Shift+F10 or Ctrl+^)* + + +After entering the source code in *scrollview.cpp* you can compile +the above program with gcc: +```cpp +g++ -O2 -lfinal -std=c++11 scrollview.cpp -o scrollview +``` diff --git a/doc/vga.txt b/doc/vga.txt new file mode 100644 index 00000000..a1ae9e9a --- /dev/null +++ b/doc/vga.txt @@ -0,0 +1,516 @@ +3C0h: Attribute Controller: Address register +bit 0-4 Address of data register to write to port 3C0h or read from port 3C1h + (Reads only on VGA). + 5 If set screen output is enabled and the palette can not be modified, + if clear screen output is disabled and the palette can be modified. + + +Port 3C0h is special in that it is both address and data-write register. +Data reads happen from port 3C1h. An internal flip-flop remembers whether it +is currently acting as address or data register. +Accesses to the attribute controller must be separated by at least 250ns. +Reading port 3dAh will reset the flip-flop to address mode. + + +3C0h index 0-Fh (r/W): Attribute: Palette +bit 0 (EGA) Primary Blue + 1 (EGA) Primary Green + 2 (EGA) Primary Red + 3 (EGA) Secondary Blue + 4 (EGA) Secondary Green + 5 (EGA) Secondary Red + 0-5 (VGA) Index into the 256 color DAC table. + May be modified by 3C0h index 10h and 14h. + +3C0h index 10h (r/W): Attribute: Mode Control Register +bit 0 Graphics mode if set, Alphanumeric mode else. + 1 Monochrome mode if set, color mode else. + 2 9-bit wide characters if set. + The 9th bit of characters C0h-DFh will be the same as + the 8th bit. Otherwise it will be the background color. + 3 If set Attribute bit 7 is blinking, else high intensity. + 5 (VGA Only) If set the PEL panning register (3C0h index 13h) is + temporarily set to 0 from when the line compare causes a wrap around + until the next vertical retrace when the register is automatically + reloaded with the old value, else the PEL panning register ignores + line compares. + 6 (VGA Only) If set pixels are 8 bits wide. Used in 256 color modes. + 7 (VGA Only) If set bit 4-5 of the index into the DAC table are taken + from port 3C0h index 14h bit 0-1, else the bits in the palette + register are used. + +3C0h index 11h (r/W): Attribute: Overscan Color Register. +bit 0-5 Color of screen border. Color is defined as in the palette registers. +Note: The EGA requires the Overscan color to be 0 in high resolution modes. + +3C0h index 12h (r/W): Attribute: Color Plane Enable Register +bit 0 Bit plane 0 is enabled if set. + 1 Bit plane 1 is enabled if set. + 2 Bit plane 2 is enabled if set. + 3 Bit plane 3 is enabled if set. + 4-5 Video Status MUX. Diagnostics use only. + Two attribute bits appear on bits 4 and 5 of the Input + Status Register 1 (3dAh). + Value EGA VGA + 0 Red/Blue Bit 2/Bit 0 + 1 Blue'/Green Bit 5/Bit 4 + 2 Red'/Green' Bit 3/Bit 1 + 3 Bit 7/Bit 6 + +3C0h index 13h (r/W): Attribute: Horizontal PEL Panning Register +bit 0-3 Indicates number of pixels to shift the display left + Value 9bit textmode 256color mode Other modes + 0 1 0 0 + 1 2 n/a 1 + 2 3 1 2 + 3 4 n/a 3 + 4 5 2 4 + 5 6 n/a 5 + 6 7 3 6 + 7 8 n/a 7 + 8 0 n/a n/a + +3C0h index 14h (r/W): Attribute: Color Select Register (VGA Only) +bit 0-1 If 3C0h index 10h bit 7 is set these 2 bits are used as bits 4-5 of + the index into the DAC table. + 2-3 These 2 bits are used as bit 6-7 of the index into the DAC table + except in 256 color mode. +Note: this register does not affect 256 color modes. + +3C2h (R): Input Status #0 Register +bit 4 Status of the switch selected by the Miscellaneous Output + Register 3C2h bit 2-3. Switch high if set. + 5 (EGA Only) Pin 19 of the Feature Connector (FEAT0) is high if set + 6 (EGA Only) Pin 17 of the Feature Connector (FEAT1) is high if set + 7 (EGA Only ??) If set IRQ 2 has happened due to Vertical Retrace. + Should be cleared by IRQ 2 interrupt routine by clearing port 3d4h + index 11h bit 4. + +3C2h (W): Miscellaneous Output Register +bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base + Address=3Bxh. + 1 Enable CPU Access to video memory if set + 2-3 Clock Select + 0: 14MHz(EGA) 25MHz(VGA) + 1: 16MHz(EGA) 28MHz(VGA) + 2: External(EGA) Reserved(VGA) + 4 (EGA Only) Disable internal video drivers if set + 5 When in Odd/Even modes Select High 64k bank if set + 6 Horizontal Sync Polarity. Negative if set + 7 Vertical Sync Polarity. Negative if set + Bit 6-7 indicates the number of lines on the display: + 0=200(EGA) Reserved(VGA) + 1= 400(VGA) + 2=350(EGA) 350(VGA) + 3= 480(VGA). +Note: Set to all zero on a hardware reset. +Note: On the VGA this register can be read from port 3CCh. + +3C3h (W): Video Subsystem Enable Register +bit 0 Enables the VGA display if set + +3C4h index 0 (r/W): Sequencer: Reset +bit 0 (EGA) Asynchronous Reset if clear + 0 (VGA) Synchronous Reset just as bit 1 + 1 Synchronous Reset if clear + +3C4h index 1 (r/W): Sequencer: Clocking Mode +bit 0 If set character clocks are 8 dots wide, else 9. + 1 (EGA Only) If set the CRTC uses 2/5 of the clock cycles, else 4/5. + 2 If set loads video serializers every other character + clock cycle, else every one. + 3 If set the Dot Clock is Master Clock/2, else same as + Master Clock (See 3C2h bit 2-3). (Doubles pixels). + 4 (VGA Only) If set loads video serializers every fourth character + clock cycle, else every one. + 5 (VGA Only) if set turns off screen and gives all memory cycles to the + CPU interface. + +3C4h index 2 (r/W): Sequencer: Map Mask Register +bit 0 Enable writes to plane 0 if set + 1 Enable writes to plane 1 if set + 2 Enable writes to plane 2 if set + 3 Enable writes to plane 3 if set + +3C4h index 3 (r/W): Sequencer: Character Map Select Register +bit 0-1 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character + attribute is clear. + 2-3 (EGA) Selects EGA Character Map (0..3) if bit 3 of the character + attribute is set. + 0,1,4 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character + attribute is clear. + 2,3,5 (VGA) Selects VGA Character Map (0..7) if bit 3 of the character + attribute is set. +Note: Character Maps are placed at: + Map no. (EGA/VGA) Map no. (VGA) + 0 0k 4 8k + 1 16k 5 24k + 2 32k 6 40k + 3 48k 7 56k + +3C4h index 4 (r/W): Sequencer: Memory Mode Register +bit 0 Set if in an alphanumeric mode, clear in graphics modes. + 1 Set if more than 64kbytes on the adapter. + 2 Enables Odd/Even addressing mode if set. Odd/Even mode places all odd + bytes in plane 1&3, and all even bytes in plane 0&2. + 3 (VGA Only) If set address bit 0-1 selects video memory planes + (256 color mode), rather than the Map Mask and Read Map Select + Registers. + +3C4h index 7 (R/W): Sequencer Horizontal Character Counter Reset Register. + (VGA Only) +Note: Undocumented by IBM. May not be available in all clones. + A write to this register will cause the Horizontal Character Counter + to be held reset (=0) until a write happens to any of the Sequencer + registers index 0..6. + The Vertical Line counter is clocked by a signal derived from the + Horizontal Display Enable (which does not occur if the Horizontal + Character Counter is held reset). + Thus a write to index 7 during Vertical Retrace can stop the display + timing and allow software to start the next frame reasonably + synchronous to an external event. + +3C6h (R/W): PEL Mask (VGA Only) +bit 0-7 This register is anded with the palette index sent for each dot. + Should be set to FFh. + +3C7h (R): DAC State Register (VGA Only) +bit 0-1 0 indicates the DAC is in Read Mode and 3 indicates write mode. + +3C7h (W): PEL Address Read Mode (VGA Only) +bit 0-7 The PEL data register (0..255) to be read from 3C9h. +Note: After reading the 3 bytes at 3C9h this register will increment, + pointing to the next data register. + +3C8h (R/W): PEL Address Write Mode (VGA Only) +bit 0-7 The PEL data register (0..255) to be written to 3C9h. +Note: After writing the 3 bytes at 3C9h this register will increment, pointing + to the next data register. + +3C9h (R/W): PEL Data Register (VGA Only) +bit 0-5 Color value +Note: Each read or write of this register will cycle through first the + registers for Red, Blue and Green, then increment the appropriate + address register, thus the entire palette can be loaded by writing 0 to + the PEL Address Write Mode register 3C8h and then writing all 768 bytes + of the palette to this register. + +3CAh (R): Feature Control Register (VGA Only) +Bit 3 Vertical Sync Select. If set Vertical Sync to the monitor is the + logical OR of the vertical sync and the vertical display enable. +Note: This register is written to port 3dAh and read from 3CAh. + +3CAh (W): Graphics 2 Position (EGA Only) +bit 0-1 Select which bit planes should be controlled by Graphics Controller + #2. Always set to 1. + +3CCh (R): Miscellaneous Output Register (VGA Only) +bit 0 If set Color Emulation. Base Address=3Dxh else Mono Emulation. Base + Address=3Bxh. + 1 Enable CPU Access to video memory if set + 2-3 Clock Select. 0= 25MHz, 1= 28MHz, 2= Reserved + 5 When in Odd/Even modes Select High 64k bank if set + 6 Horizontal Sync Polarity. Negative if set + 7 Vertical Sync Polarity. Negative if set + Bit 6-7 indicates the number of lines on the display: + 0=Reserved, 1=400, 2=350, 3=480. +Note: This register is written to port 3C2h and read from port 3CCh. + +3CCh (W): Graphics 1 Position (EGA Only) +bit 0-1 Select which bit planes should be controlled by Graphics Controller + #1. Always set to 0. + +3CEh index 0 (r/W): Graphics: Set/Reset Register +bit 0 If in Write Mode 0 and bit 0 of 3CEh index 1 is set a write to + display memory will set all the bits in plane 0 of the byte to this + bit, if the corresponding bit is set in the Map Mask Register (3CEh + index 8). + 1 Same for plane 1 and bit 1 of 3CEh index 1. + 2 Same for plane 2 and bit 2 of 3CEh index 1. + 3 Same for plane 3 and bit 3 of 3CEh index 1. + +3CEh index 1 (r/W): Graphics: Enable Set/Reset Register +bit 0 If set enables Set/reset of plane 0 in Write Mode 0. + 1 Same for plane 1. + 2 Same for plane 2. + 3 Same for plane 3. + +3CEh index 2 (r/W): Graphics: Color Compare Register +bit 0-3 In Read Mode 1 each pixel at the address of the byte read is compared + to this color and the corresponding bit in the output set to 1 if + they match, 0 if not. The Color Don't Care Register (3CEh index 7) + can exclude bitplanes from the comparison. + +3CEh index 3 (r/W): Graphics: Data Rotate +bit 0-2 Number of positions to rotate data right before it is written to + display memory. Only active in Write Mode 0. + 3-4 In Write Mode 2 this field controls the relation between the data + written from the CPU, the data latched from the previous read and the + data written to display memory: + 0: CPU Data is written unmodified + 1: CPU data is ANDed with the latched data + 2: CPU data is ORed with the latch data. + 3: CPU data is XORed with the latched data. + +3CEh index 4 (r/W): Graphics: Read Map Select Register +bit 0-1 Number of the plane Read Mode 0 will read from. + +3CEh index 5 (r/W): Graphics: Mode Register +bit 0-1 Write Mode: Controls how data from the CPU is transformed before + being written to display memory: + 0: Mode 0 works as a Read-Modify-Write operation. + First a read access loads the data latches of the EGA/VGA with + the value in video memory at the addressed location. Then a + write access will provide the destination address and the CPU + data byte. The data written is modified by the function code in + the Data Rotate register (3CEh index 3) as a function of the CPU + data and the latches, then data is rotated as specified by the + same register. + 1: Mode 1 is used for video to video transfers. + A read access will load the data latches with the contents of + the addressed byte of video memory. A write access will write + the contents of the latches to the addressed byte. Thus a single + MOVSB instruction can copy all pixels in the source address byte + to the destination address. + 2: Mode 2 writes a color to all pixels in the addressed byte of + video memory. Bit 0 of the CPU data is written to plane 0 et + cetera. Individual bits can be enabled or disabled through the + Bit Mask register (3CEh index 8). + 3: (VGA Only) Mode 3 can be used to fill an area with a color and + pattern. The CPU data is rotated according to 3CEh index 3 bits + 0-2 and anded with the Bit Mask Register (3CEh index 8). For + each bit in the result the corresponding pixel is set to the + color in the Set/Reset Register (3CEh index 0 bits 0-3) if the + bit is set and to the contents of the processor latch if the bit + is clear. + 2 (EGA Only) Forces all outputs to a high impedance state if set. + 3 Read Mode + 0: Data is read from one of 4 bit planes depending on the Read Map + Select Register (3CEh index 4). + 1: Data returned is a comparison between the 8 pixels occupying the + read byte and the color in the Color Compare Register (3CEh + index 2). A bit is set if the color of the corresponding pixel + matches the register. + 4 Enables Odd/Even mode if set (See 3C4h index 4 bit 2). + 5 Enables CGA style 4 color pixels using even/odd bit pairs if set. + 6 (VGA Only) Enables 256 color mode if set. + +3CEh index 6 (r/W): Graphics: Miscellaneous Register +bit 0 Indicates Graphics Mode if set, Alphanumeric mode else. + 1 Enables Odd/Even mode if set. + 2-3 Memory Mapping: + 0: use A000h-BFFFh + 1: use A000h-AFFFh EGA/VGA Graphics modes + 2: use B000h-B7FFh Monochrome modes + 3: use B800h-BFFFh CGA modes + +3CEh index 7 (r/W): Graphics: Color Don't Care Register +bit 0 Ignore bit plane 0 in Read mode 1 if clear. + 1 Ignore bit plane 1 in Read mode 1 if clear. + 2 Ignore bit plane 2 in Read mode 1 if clear. + 3 Ignore bit plane 3 in Read mode 1 if clear. + +3CEh index 8 (r/W): Graphics: Bit Mask Register +bit 0-7 Each bit if set enables writing to the corresponding bit of a byte in + display memory. + +3d4h index 0 (r/W): CRTC: Horizontal Total Register +bit 0-7 (EGA) Horizontal Total Character Clocks-2 + 0-7 (VGA) Horizontal Total Character Clocks-5 + +3d4h index 1 (r/W): CRTC: Horizontal Display End Register +bit 0-7 Number of Character Clocks Displayed -1 + +3d4h index 2 (r/W): CRTC: Start Horizontal Blanking Register +bit 0-7 The count at which Horizontal Blanking starts + +3d4h index 3 (r/W): CRTC: End Horizontal Blanking Register +bit 0-4 Horizontal Blanking ends when the last 5 (6 for VGA) bits of the + character counter equals this field. + (VGA) The sixth bit is found in port 3d4h index 5 bit 7. + 5-6 Number of character clocks to delay start of display after Horizontal + Total has been reached. + 7 (VGA Only) Access to Vertical Retrace registers if set. If clear + reads to 3d4h index 10h and 11h access the Lightpen read back + registers ?? + +3d4h index 4 (r/W): CRTC: Start Horizontal Retrace Register +bit 0-7 Horizontal Retrace starts when the Character Counter reaches this + value. + +3d4h index 5 (r/W): CRTC: End Horizontal Retrace Register +bit 0-4 Horizontal Retrace ends when the last 5 bits of the character counter + equals this value. + 5-6 Number of character clocks to delay start of display after Horizontal + Retrace. + 7 (EGA) Provides Smooth Scrolling in Odd/Even mode. When set display + starts from an odd byte. + 7 (VGA) bit 5 of the End Horizontal Blanking count (See 3d4h index 3 + bit 0-4). + +3d4h index 6 (r/W): CRTC: Vertical Total Register +bit 0-7 Lower 8 bits of the Vertical Total. Bit 8 is found in 3d4h index 7 + bit 0. (VGA) Bit 9 is found in 3d4h index 7 bit 5. +Note: For the VGA this value is the number of scan lines in the display -2. + +3d4h index 7 (r/W): CRTC: Overflow Register +bit 0 Bit 8 of Vertical Total (3d4h index 6) + 1 Bit 8 of Vertical Display End (3d4h index 12h) + 2 Bit 8 of Vertical Retrace Start (3d4h index 10h) + 3 Bit 8 of Start Vertical Blanking (3d4h index 15h) + 4 Bit 8 of Line Compare Register (3d4h index 18h) + 5 (VGA) Bit 9 of Vertical Total (3d4h index 6) + 6 (VGA) Bit 9 of Vertical Display End (3d4h index 12h) + 7 (VGA) Bit 9 of Vertical Retrace Start (3d4h index 10h) + +3d4h index 8 (r/W): CRTC: Preset Row Scan Register +bit 0-4 Number of lines we have scrolled down in the first character row. + Provides Smooth Vertical Scrolling. + 5-6 (VGA Only) Number of bytes to skip at the start of scanline. Provides + Smooth Horizontal Scrolling together with the Horizontal Panning + Register (3C0h index 13h). + +3d4h index 9 (r/W): CRTC: Maximum Scan Line Register +bit 0-4 Number of scan lines in a character row -1. In graphics modes this is + the number of times (-1) the line is displayed before passing on to + the next line (0: normal, 1: double, 2: triple...). + This is independent of bit 7, except in CGA modes which seems to + require this field to be 1 and bit 7 to be set to work. + 5 (VGA) Bit 9 of Start Vertical Blanking + 6 (VGA) Bit 9 of Line Compare Register + 7 (VGA) Doubles each scan line if set. + I.e. displays 200 lines on a 400 display. + +3d4h index Ah (r/W): CRTC: Cursor Start Register +bit 0-4 First scanline of cursor within character. + 5 (VGA) Turns Cursor off if set + +3d4h index Bh (r/W): CRTC: Cursor End Register +bit 0-4 Last scanline of cursor within character + 5-6 Delay of cursor data in character clocks. + +3d4h index Ch (r/W): CRTC: Start Address High Register +bit 0-7 Upper 8 bits of the start address of the display buffer + +3d4h index Dh (r/W): CRTC: Start Address Low Register +bit 0-7 Lower 8 bits of the start address of the display buffer + +3d4h index Eh (r/W): CRTC: Cursor Location High Register +bit 0-7 Upper 8 bits of the address of the cursor + +3d4h index Fh (r/W): CRTC: Cursor Location Low Register +bit 0-7 Lower 8 bits of the address of the cursor + +3d4h index 10h (R): CRTC: Light Pen High Register (EGA Only) +bit 0-7 (EGA Only) Upper 8 bits of the address of the lightpen position. + +3d4h index 10h (r/W): CRTC: Vertical Retrace Start Register +bit 0-7 Lower 8 bits of Vertical Retrace Start. Vertical Retrace starts when + the line counter reaches this value. Bit 8 is found in 3d4h index 7 + bit 2. (VGA Only) Bit 9 is found in 3d4h index 7 bit 7. + +3d4h index 11h (R): CRTC: Light Pen Low Register (EGA Only) +bit 0-7 (EGA Only) Lower 8 bits of the address of the lightpen position. + +3d4h index 11h (r/W): CRTC: Vertical Retrace End Register +bit 0-3 Vertical Retrace ends when the last 4 bits of the line counter equals + this value. + 4 if clear Clears pending Vertical Interrupts. + 5 Vertical Interrupts (IRQ 2) disabled if set. Can usually be left + disabled, but some systems (including PS/2) require it to be enabled. + 6 (VGA Only) If set selects 5 refresh cycles per scanline rather + than 3. + 7 (VGA Only) Disables writing to registers 0-7 if set 3d4h index 7 + bit 4 is not affected by this bit. + +3d4h index 12h (r/W): CRTC: Vertical Display End Register +bit 0-7 Lower 8 bits of Vertical Display End. The display ends when the line + counter reaches this value. Bit 8 is found in 3d4h index 7 bit 1. + (VGA Only) Bit 9 is found in 3d4h index 7 bit 6. + +3d4h index 13h (r/W): CRTC: Offset register +bit 0-7 Number of bytes in a scanline / K. Where K is 2 for byte mode, 4 for + word mode and 8 for Double Word mode. + +3d4h index 14h (r/W): CRTC: Underline Location Register +bit 0-4 Position of underline within Character cell. + 5 (VGA Only) If set memory address is only changed every fourth + character clock. + 6 (VGA Only) Double Word mode addressing if set + +3d4h index 15h (r/W): CRTC: Start Vertical Blank Register +bit 0-7 Lower 8 bits of Vertical Blank Start. Vertical blanking starts when + the line counter reaches this value. Bit 8 is found in 3d4h index 7 + bit 3. + +3d4h index 16h (r/W): CRTC: End Vertical Blank Register +bit 0-4 (EGA) Vertical blanking stops when the lower 5 bits of the line + counter equals this field. + 0-6 (VGA) Vertical blanking stops when the lower 7 bits of the line + counter equals this field. + +3d4h index 17h (r/W): CRTC: Mode Control Register +bit 0 If clear use CGA compatible memory addressing system + by substituting character row scan counter bit 0 for address bit 13, + thus creating 2 banks for even and odd scan lines. + 1 If clear use Hercules compatible memory addressing system by + substituting character row scan counter bit 1 for address bit 14, + thus creating 4 banks. + 2 If set increase scan line counter only every second line. + 3 If set increase memory address counter only every other character + clock. + 4 (EGA Only) If set disable the EGA output drivers. This bit is used + for other purposes in some Super VGA chips. + 5 When in Word Mode bit 15 is rotated to bit 0 if this bit is set else + bit 13 is rotated into bit 0. + 6 If clear system is in word mode. Addresses are rotated 1 position up + bringing either bit 13 or 15 into bit 0. + 7 Clearing this bit will reset the display system until the bit is set + again. + +3d4h index 18h (r/W): CRTC: Line Compare Register +bit 0-7 Lower 8 bits of the Line Compare. When the Line counter reaches this + value, the display address wraps to 0. Provides Split Screen + facilities. Bit 8 is found in 3d4h index 7 bit 4. + (VGA Only) Bit 9 is found in 3d4h index 9 bit 6. + +3d4h index 22h (R): Memory Latch Register (VGA - Undoc) +bit 0-7 Reads the contents of the Graphics Controller Memory Data Latch for + the plane selected by 3C0h index 4 bit 0-1 (Read Map Select). +Note: This register is not documented by IBM and may not be available on all + clones. + +3d4h index 24h (R): Attribute Controller Toggle Register. (VGA - Undoc) +bit 0-4 Attribute Controller Index. + The current value of the Attribute Index Register. + 5 Palette Address Source. Same as 3C0h bit 5. + 7 If set next read or write to 3C0h will access the data register. +Note: This register is not documented by IBM and may not be available on all + clones. + +3d4h index 30h-3Fh (W): Clear Vertical Display Enable. (VGA - Undoc) +bit 0 Setting this bit will clear the Vertical Display Enable thus blanking + the display for the rest of the frame and giving the CPU total access + to display memory until the start of the next frame. +Note: This register is not documented by IBM and may not be available on all + clones. + +3dAh (R): Input Status #1 Register +bit 0 Either Vertical or Horizontal Retrace active if set + 1 (EGA Only) Light Pen has triggered if set + 2 (EGA Only) Light Pen switch is open if set + 3 Vertical Retrace in progress if set + 4-5 (EGA Only) Shows two of the 6 color outputs, depending on 3C0h index + 12h bit 4-5: + Attr: Bit 4-5: Out bit 4 Out bit 5 + 0 Blue Red + 1 I Blue Green + 2 I Red I Green + +3dAh (W): Feature Control Register +bit 0 (EGA Only) Output to pin 21 of the Feature Connector. + 1 (EGA Only) Output to pin 20 of the Feature Connector. + 3 (VGA Only) Vertical Sync Select. If set Vertical Sync to the monitor + is the logical OR of the vertical sync and the vertical display + enable. +Note: On the VGA this register can be read from port 3CAh. diff --git a/examples/7segment.cpp b/examples/7segment.cpp new file mode 100644 index 00000000..ecc1ff02 --- /dev/null +++ b/examples/7segment.cpp @@ -0,0 +1,233 @@ +/*********************************************************************** +* 7segment.cpp - Seven-segment display * +* * +* This file is part of the Final Cut widget toolkit * +* * +* Copyright 2012-2019 Markus Gans * +* * +* The Final Cut is free software; you can redistribute it and/or * +* modify it under the terms of the GNU Lesser General Public License * +* as published by the Free Software Foundation; either version 3 of * +* the License, or (at your option) any later version. * +* * +* The Final Cut is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public * +* License along with this program. If not, see * +* . * +***********************************************************************/ + +#include +#include + +#include + +namespace fc = finalcut::fc; +using finalcut::FColorPair; +using finalcut::FRect; +using finalcut::FPoint; +using finalcut::FSize; + + +//---------------------------------------------------------------------- +// class TextWindow +//---------------------------------------------------------------------- + +class SegmentView : public finalcut::FDialog +{ + public: + explicit SegmentView (finalcut::FWidget* = nullptr); + + private: + // Typedef + typedef struct + { + unsigned char a : 1; + unsigned char b : 1; + unsigned char c : 1; + unsigned char d : 1; + unsigned char e : 1; + unsigned char f : 1; + unsigned char g : 1; + unsigned char : 1; // padding bit + } sevenSegment; + + // Methods + void hexEncoding(); + void get7Segment (const wchar_t); + void draw() override; + + // Data members + std::map code{}; + finalcut::FString line[3]; + finalcut::FLineEdit Input{"0123", this}; + finalcut::FButton Exit{"E&xit", this}; +}; + +//---------------------------------------------------------------------- +SegmentView::SegmentView (finalcut::FWidget* parent) + : FDialog(parent) +{ + // Set encoding + hexEncoding(); + + // Dialog settings + setText ("Seven-segment display"); + setGeometry (FPoint(25, 5), FSize(42, 15)); + + // Input field + Input.setGeometry (FPoint(2, 2), FSize(12, 1)); + Input.setLabelText (L"&Hex value"); + Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)"); + Input.setLabelOrientation(finalcut::FLineEdit::label_above); + Input.setMaxLength(9); + Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]"); + + // Exit button + Exit.setGeometry(FPoint(28, 11), FSize(10, 1)); + + // Add some function callbacks + Input.addCallback + ( + "changed", + [] (finalcut::FWidget*, FDataPtr data) + { + auto dialog = static_cast(data); + dialog->redraw(); + }, + this + ); + + Exit.addCallback + ( + "clicked", + F_METHOD_CALLBACK (this, &finalcut::FApplication::cb_exitApp) + ); +} + +//---------------------------------------------------------------------- +void SegmentView::hexEncoding() +{ + code['0'] = sevenSegment{1, 1, 1, 1, 1, 1, 0}; + code['1'] = sevenSegment{0, 1, 1, 0, 0, 0, 0}; + code['2'] = sevenSegment{1, 1, 0, 1, 1, 0, 1}; + code['3'] = sevenSegment{1, 1, 1, 1, 0, 0, 1}; + code['4'] = sevenSegment{0, 1, 1, 0, 0, 1, 1}; + code['5'] = sevenSegment{1, 0, 1, 1, 0, 1, 1}; + code['6'] = sevenSegment{1, 0, 1, 1, 1, 1, 1}; + code['7'] = sevenSegment{1, 1, 1, 0, 0, 0, 0}; + code['8'] = sevenSegment{1, 1, 1, 1, 1, 1, 1}; + code['9'] = sevenSegment{1, 1, 1, 1, 0, 1, 1}; + code['A'] = sevenSegment{1, 1, 1, 0, 1, 1, 1}; + code['B'] = sevenSegment{0, 0, 1, 1, 1, 1, 1}; + code['C'] = sevenSegment{1, 0, 0, 1, 1, 1, 0}; + code['D'] = sevenSegment{0, 1, 1, 1, 1, 0, 1}; + code['E'] = sevenSegment{1, 0, 0, 1, 1, 1, 1}; + code['F'] = sevenSegment{1, 0, 0, 0, 1, 1, 1}; +} + +//---------------------------------------------------------------------- +void SegmentView::get7Segment (const wchar_t c) +{ + for (int i{0}; i < 3; i++) + line[i].clear(); + + switch ( c ) + { + case ':': + line[0] = ' '; + line[1] = '.'; + line[2] = '.'; + break; + + case '.': + line[0] = ' '; + line[1] = ' '; + line[2] = '.'; + break; + + case 'H': + line[0] = " "; + line[1] = "|_|"; + line[2] = "| |"; + break; + + case 'L': + line[0] = " "; + line[1] = "| "; + line[2] = "|_ "; + break; + + case 'P': + line[0] = " _ "; + line[1] = "|_|"; + line[2] = "| "; + break; + + case 'U': + line[0] = " "; + line[1] = "| |"; + line[2] = "|_|"; + break; + + default: + // Hexadecimal digit from 0 up to f + if ( code.find(c) != code.end() ) + { + sevenSegment& s = code[c]; + constexpr char h[2]{' ', '_'}; + constexpr char v[2]{' ', '|'}; + + line[0] << ' ' << h[s.a] << ' '; + line[1] << v[s.f] << h[s.g] << v[s.b]; + line[2] << v[s.e] << h[s.d] << v[s.c]; + } + } +} + +//---------------------------------------------------------------------- +void SegmentView::draw() +{ + std::vector tbuffer{3}; + finalcut::FTermBuffer left_space{}; + + FDialog::draw(); + setColor(fc::LightGray, fc::Black); + finalcut::drawBorder(this, FRect(FPoint(3, 6), FPoint(40, 11))); + + for (auto&& ch : Input.getText().toUpper()) + { + FColorPair color(fc::LightRed, fc::Black); + get7Segment(ch); + + for (std::size_t i{0}; i < 3; i++) + tbuffer[i] << color << line[i] << " "; + } + + std::size_t length = tbuffer[0].getLength(); + + if ( length < 36 ) + left_space << finalcut::FString(36 - length, ' '); + + print() << FPoint (4, 7) << left_space << tbuffer[0] + << FPoint (4, 8) << left_space << tbuffer[1] + << FPoint (4, 9) << left_space << tbuffer[2] + << FPoint (4, 10) << finalcut::FString(36, ' '); +} + + +//---------------------------------------------------------------------- +// main part +//---------------------------------------------------------------------- + +int main (int argc, char* argv[]) +{ + finalcut::FApplication app(argc, argv); + SegmentView dialog(&app); + app.setMainWidget(&dialog); + dialog.show(); + return app.exec(); +} diff --git a/examples/Makefile.am b/examples/Makefile.am index f0a0304e..2722af3b 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -11,6 +11,8 @@ noinst_PROGRAMS = \ hello \ dialog \ input-dialog \ + fullwidth-character \ + 7segment \ choice \ listbox \ listview \ @@ -35,6 +37,8 @@ noinst_PROGRAMS = \ hello_SOURCES = hello.cpp dialog_SOURCES = dialog.cpp input_dialog_SOURCES = input-dialog.cpp +fullwidth_character_SOURCES = fullwidth-character.cpp +7segment_SOURCES = 7segment.cpp choice_SOURCES = choice.cpp listbox_SOURCES = listbox.cpp listview_SOURCES = listview.cpp diff --git a/examples/Makefile.clang b/examples/Makefile.clang index 3d094f1c..e761ef01 100644 --- a/examples/Makefile.clang +++ b/examples/Makefile.clang @@ -29,7 +29,7 @@ endif all: $(OBJS) debug: - $(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wpadded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro" + $(MAKE) $(MAKEFILE) DEBUG="-g -D DEBUG -Wall -Wextra -Wpedantic -Weverything -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-implicit-fallthrough -Wno-reserved-id-macro" profile: $(MAKE) $(MAKEFILE) PROFILE="-pg" diff --git a/examples/calculator.cpp b/examples/calculator.cpp index ed5d7735..e7bdf3e4 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -30,20 +30,18 @@ #include +namespace fc = finalcut::fc; using finalcut::FPoint; using finalcut::FSize; using finalcut::FColorPair; -constexpr lDouble PI = 3.141592653589793238L; +constexpr lDouble PI{3.141592653589793238L}; //---------------------------------------------------------------------- // class Button //---------------------------------------------------------------------- -#pragma pack(push) -#pragma pack(1) - class Button : public finalcut::FButton { public: @@ -54,13 +52,12 @@ class Button : public finalcut::FButton void setChecked(bool); // Event handler - virtual void onKeyPress (finalcut::FKeyEvent*) override; + void onKeyPress (finalcut::FKeyEvent*) override; private: - // Data Member + // Data member bool checked{false}; }; -#pragma pack(pop) //---------------------------------------------------------------------- Button::Button (finalcut::FWidget* parent) @@ -77,12 +74,13 @@ void Button::setChecked (bool enable) if ( checked ) { - setBackgroundColor(finalcut::fc::Cyan); - setFocusForegroundColor(finalcut::fc::White); - setFocusBackgroundColor(finalcut::fc::Cyan); + setBackgroundColor(fc::Cyan); + setFocusForegroundColor(fc::White); + setFocusBackgroundColor(fc::Cyan); } else { + const finalcut::FWidgetColors& wc = getFWidgetColors(); setBackgroundColor(wc.button_active_bg); setFocusForegroundColor(wc.button_active_focus_fg); setFocusBackgroundColor(wc.button_active_focus_bg); @@ -97,8 +95,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev) FKey key = ev->key(); // catch the enter key - if ( key == finalcut::fc::Fkey_return - || key == finalcut::fc::Fkey_enter ) + if ( key == fc::Fkey_return || key == fc::Fkey_enter ) return; finalcut::FButton::onKeyPress(ev); @@ -109,9 +106,6 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev) // class Calc //---------------------------------------------------------------------- -#pragma pack(push) -#pragma pack(1) - class Calc : public finalcut::FDialog { public: @@ -122,8 +116,8 @@ class Calc : public finalcut::FDialog ~Calc(); // Event handlers - virtual void onKeyPress (finalcut::FKeyEvent*) override; - virtual void onClose (finalcut::FCloseEvent*) override; + void onKeyPress (finalcut::FKeyEvent*) override; + void onClose (finalcut::FCloseEvent*) override; // Callback method void cb_buttonClicked (finalcut::FWidget*, FDataPtr); @@ -173,7 +167,7 @@ class Calc : public finalcut::FDialog // Methods void drawDispay(); - virtual void draw() override; + void draw() override; void clear (lDouble&); void zero (lDouble&); void one (lDouble&); @@ -215,11 +209,11 @@ class Calc : public finalcut::FDialog void setInfixOperator (char); void clearInfixOperator(); void calcInfixOperator(); - virtual void adjustSize() override; + void adjustSize() override; const wchar_t* getButtonText (std::size_t); void mapKeyFunctions(); - // Data Members + // Data members bool error{false}; bool arcus_mode{false}; bool hyperbolic_mode{false}; @@ -243,7 +237,6 @@ class Calc : public finalcut::FDialog std::map > calculator_buttons{}; std::map key_map{}; }; -#pragma pack(pop) //---------------------------------------------------------------------- Calc::Calc (FWidget* parent) @@ -255,7 +248,7 @@ Calc::Calc (FWidget* parent) setText ("Calculator"); setGeometry (FPoint(19, 6), FSize(37, 18)); - for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++) + for (std::size_t key{0}; key < Calc::NUM_OF_BUTTONS; key++) { auto btn = std::make_shared