Commit Graph

1309 Commits

Author SHA1 Message Date
Albrecht Schlosser
fd5cd80935 Introduce "Modern CMake" in FLTK
This is a big commit and there are too many changes to list them all.
The main changes are:

- rename all CMake build options to 'FLTK_*'
- export library targets with namespace (prefix) 'fltk::'
- standardize shared library target names with suffix '-shared'
- set public build properties on libraries for consumers
- document library names and aliases in README.CMake.txt
- document changes in "Migrating Code from FLTK 1.3 to 1.4"
- partial backwards compatibility for old user projects

Included but not directly related changes:

- fix Windows (Visual Studio) DLL build
- add CMake function fl_debug_target() to show target properties
- don't build test programs if FLTK is a subproject
- internal: reformat CMake code: remove space before '('

Thanks to Matthias and Manolo for their help, testing, and feeback.
2024-02-07 18:37:34 +01:00
Matthias Melcher
f0c1eff069 Fix typo in function name in editor. 2024-02-06 22:00:11 +01:00
Matthias Melcher
78ae78b118 Add dynamic title to test/editor 2024-02-06 21:25:43 +01:00
ManoloFLTK
6d98c6a8b1
Restore 3-way close window dialog (#900) 2024-02-06 20:27:18 +01:00
Matthias Melcher
d9612e3cc7
RFC: Different approach to Editor tutorial (see #189) (#883)
Update test/editor code and tutorial (#189, #883)

Different, sequential approach to Editor tutorial
Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
2024-01-29 11:43:34 +01:00
Matthias Melcher
554bccbecd Synchronize mouse and keyboard callbacks for Fl_Button (#877)
Keyboard behavior for button types was not consistent with mouse
click behavior. This change avoids callbacks when pressed radio buttons
are pressed again.
2024-01-17 20:24:47 +01:00
ManoloFLTK
8679be8561 Restore correct copyright window for checkers demo 2024-01-15 17:28:25 +01:00
Greg Ercolano
dc70a04100 Add Fl_String not-equal test 2024-01-10 21:32:02 -08:00
Albrecht Schlosser
b4697c33ff Remove Fl_Simple_Terminal (replaced by Fl_Terminal)
... as discussed previously.
2024-01-06 18:29:25 +01:00
Greg Ercolano
04bf5c5a34 Limit test/terminal window size
Prevents window from squishing buttons horizontally.
Allows tty height to shrink to no less than a single line.
2024-01-03 23:08:18 -08:00
Matthias Melcher
a09c75e9bc Adds Fl_Input RMB menu translation to test/preferences
This also updates the RMB menu labels before every popup so
that changing the labels after creating the widgets still reflects
that change correctly.
2023-12-28 15:43:21 +01:00
Albrecht Schlosser
76a2c95f07 Fix a typo, trailing whitespace, and dependencies 2023-12-21 14:03:04 +01:00
Albrecht Schlosser
5df5daf78e Make the 'Forms' compatibility library 'fltk_forms' optional
This library is no longer needed in FLTK itself. There is only one
demo program (test/forms.cxx) that uses it if it is built. The demo
program displays a message if fltk_forms is not available.

The default is 'enabled' for backwards compatibility but this may
be changed to 'disabled' in a future version.
2023-12-20 17:33:37 +01:00
Albrecht Schlosser
05687d1cb4 Fix typos, formatting, and text alignment in test/forms.cxx
no real code changes
2023-12-19 19:21:39 +01:00
Albrecht Schlosser
855a50a5f6 Fix MSVC compiler warning 2023-12-17 18:05:36 +01:00
Matthias Melcher
469d3ef3d5 #842: Enables command line color arguments on macOS 2023-12-16 21:59:43 +01:00
Matthias Melcher
04a5098a58 #840: Generously adds Fl::args_to_utf8() for MinGW support. 2023-12-15 13:04:57 +01:00
Matthias Melcher
33d0718756 FLUID: option to show terminal, clear terminal, and clear history 2023-12-14 19:40:34 +01:00
ManoloFLTK
3e61ec7044 New member function Fl_Image_Surface::mask(Fl_RGB_Image*) 2023-12-04 12:34:44 +01:00
Albrecht Schlosser
727bd94560 Add commandline conversion for Windows (no-op on other platforms)
- add Fl::args_to_utf8() to convert commandline arguments to UTF-8

This new function closes the gap that previously only Visual Studio
applications converted their commandlines to UTF-8.

Tested with MinGW, MSYS2/MinGW-w64, and Visual Studio (2019).
2023-11-29 16:29:54 +01:00
Albrecht Schlosser
a0e4a3fd5d Minor fixes and window size_range in new test/tile.cxx
Also add comments to clarify what "old" and "new" code is,respectively.
2023-11-29 14:42:06 +01:00
Albrecht Schlosser
57371365d8 Fix compiler warning, dependencies, and trailing whitespace
The benign warning was:
  ‘Fl_Browser_::hscrollbar’ will be initialized after [-Wreorder]
  ‘int Fl_Browser_::linespacing_’ ...
2023-11-27 15:33:53 +01:00
Matthias Melcher
34ed30fe1a Adds linespacing() to Fl_Browser_ and all derived widgets 2023-11-25 18:20:08 +01:00
Matthias Melcher
0beab855a0 Stabilizes Fl_Tile size_range mode.
- improved documentation
- new tile resize strategy
- robust against zero sized children
2023-11-23 17:19:20 +01:00
Matthias Melcher
81e26b9089 Adding size range settings to Fl_Tile, initial commit.
- some documentation missing
- Fl_Tile::resize() not satisfying yet
- minimums work, maximums currently ignored
- 0 size children may make program hang
2023-11-22 14:45:13 +01:00
Greg Ercolano
c568056244 Added output_translate(): controls lf -> crlf translation 2023-11-21 11:24:27 -08:00
Albrecht Schlosser
8b352987f6 Fix compiler warning
"extended initializer lists only available with ‘-std=c++11’ ..."
2023-11-19 19:46:36 +01:00
Albrecht Schlosser
9eaf40dd13 Small improvements of test/grid_dialog.cxx 2023-11-18 19:38:18 +01:00
Albrecht Schlosser
f19f94d284 Add Fl_Grid based dialog demo program - part 2
Add forgotten source file.
2023-11-18 18:43:54 +01:00
Albrecht Schlosser
efe3ea7115 Add Fl_Grid based dialog demo program
This is a new test program for Fl_Grid based layout and a proof of
concept for a future dialog class based on Fl_Grid.
2023-11-18 18:37:55 +01:00
Albrecht Schlosser
367d302b5f Apply two patches provided by user 'Andre' via mail
1. add missing FL_EXPORT to class Fl_Terminal
2. add missing test/wizard demo to test/Makefile
2023-11-17 19:27:00 +01:00
Greg Ercolano
38fc08c15f Added clear(), some methods protected->public
New public methods:

    void clear(void);
    void clear(Fl_Color val);

old protected methods made public:

    void clear_screen(bool scroll_to_hist=true);      // ESC [ 2 J
    void clear_screen_home(bool scroll_to_hist=true); // ESC [ H ESC [ 2 J
    void cursor_home(void);                           // ESC [ 0 H

test/terminal modified to test these, and added separate tests
for both the API and ANSI code ways to do these ops.
2023-11-16 15:45:29 -08:00
Matthias Melcher
ed7c2f1464 Fixes test/terminal box type 2023-11-15 16:46:10 +01:00
Matthias Melcher
d5a9be6b5e Uses the correct Fl_Terminal type in terminal.fl as well 2023-11-15 15:59:34 +01:00
Matthias Melcher
fc03d304e7 FLUID: fixing test/valuator.fl and test/tree.fl
Using Fl_Terminal widget instead of subclassing from Fl_Group
2023-11-15 15:48:22 +01:00
Greg Ercolano
605328e045 Added textcolor() and color(), doc fixes.
textcolor() needed for consistency, color() behavior documented.

Both added to the test/terminal app.

Elaborated on the special background "see through" color value + behavior,
tested with color() in test/terminal app.
2023-11-14 12:23:23 -08:00
Albrecht Schlosser
155909ec30 Fix compiler warning (suggest-override) 2023-11-14 19:02:08 +01:00
Albrecht Schlosser
4b315d190c Fix dependencies and whitespace issues 2023-11-14 18:14:48 +01:00
erco77
6842a43a31
Fl_Terminal widget (#800)
Pull Fl_Terminal widget from Greg's fork
2023-11-14 07:01:52 -08:00
ManoloFLTK
0ae927a00e Add Fl_Window::maximize() and Fl_Window::un_maximize() 2023-11-05 19:42:55 +01:00
Albrecht Schlosser
d9798d2840 CMake: Refactor building OpenGL and "shared" demo programs
Define GLDEMO_LIBS and GLDEMO_SHARED: these definitions can be used
  to build OpenGL demo programs that can also be built w/o OpenGL

Examples: fullscreen, handle_events, unittests
2023-11-03 15:40:58 +01:00
Albrecht Schlosser
566f3634f9 Fix compiler warning when fullscreen demo is built w/o OpenGL
Warning: -Wsuggest-override
2023-11-03 15:34:23 +01:00
Albrecht Schlosser
1209e9dcd7 Make Fl_String and Fl_Int_Vector private (#789)
- add CMake option 'OPTION_USE_STD'
- add configure option '--enable-use_std'
- move FL/Fl_String.H to src/Fl_String.H
- move FL/Fl_Int_Vector.H to src/Fl_Int_Vector.H
- remove Fl_String from demo program examples/callbacks.cxx
- remove Fl_Int_Vector from public header FL/Fl_Table.H
- some methods of Fl_Table are no longer inline
- add CMake option OPTION_USE_STD to allow std::string in some
  selected functions and methods

Experimental, may be removed before release:

- use either Fl_Int_Vector or std::vector in Fl_Table depending
  on CMake OPTION_USE_STD or configure --enable-use_std

Move all fl_filename* functions that use Fl_String to fluid

Main changes in fluid:
 - add fluid_filename.h and .cxx
 - include "fluid_filename.h" rather than <FL/filename.H>

Update fl_input(), fl_password() and test/ask

- add maxchar parameter to fl_input() and fl_password()
- fl_input_str() and fl_password_str() are optional and return
  std::string if enabled (FLTK_USE_STD)
2023-10-22 19:35:17 +02:00
Matthias Melcher
bbf0ea664d Removes dependency on Fl_Preferences::get/set(.., Fl_String, ...) 2023-10-21 18:41:57 +02:00
Albrecht Schlosser
757b5c1227 Fix ctrl/+/- in cube demo
- Fl_Grid: force layout() on resize() - needed for GL subwindows

- test/cube.cxx:
  - use end() in constructor of class cube_box
  - ensure not to change the current group when adding a button
2023-10-20 11:28:08 +02:00
Albrecht Schlosser
38871c5b31 Add Fl_Grid widget and test and demo programs
- FL/Fl_Grid.H: header file
- src/Fl_Grid.cxx: implementation

- examples/grid-simple.cxx: simple example program
- test/cube.cxx:            use Fl_Grid for layout
- test/grid_alignment.cxx:  test cell alignment and other functions
- test/grid_buttons.cxx:    demo program as discussed in fltk.general
- test/grid_login.cxx:      like test/flex_login.cxx but with Fl_Grid
- test/flex_login.cxx:      modified to match test/grid_login.cxx
2023-10-16 22:18:24 +02:00
Albrecht Schlosser
7e71cea54a Update .gitignore files
Add missing executables
2023-10-16 21:10:27 +02:00
Albrecht Schlosser
6ba7b49baf Improve subclassing cababilities of Fl_Tile (STR 2791)
- remove static variables and functions
- make move_intersection() virtual
- add (protected) cursor access methods

These changes were inspired by STR 2791 where the user proposing an
enhancement was not able to subclass Fl_Tile properly. This commit
fixes the mentioned issues and enables subclassing without copying
internal code.
2023-10-16 13:33:40 +02:00
Albrecht Schlosser
01038e832a Fix trailing whitespace and dependencies 2023-10-13 19:08:30 +02:00
Matthias Melcher
0af27f6fda test/menubar: use popup menu default boxtype 2023-10-13 12:11:16 +02:00
Albrecht Schlosser
1fd6f0dd3a Fix STR 3458: "GLUT compatibility mode segfaults"
... "when there's no current window".

Silently ignore GLUT function calls that need a current window if the
current window is NULL, return 0 from functions that return an 'int'.

Check if window is shown in Fl_X11_Gl_Window_Driver::swap_buffers().
This would issue "XRequest.nnn: GLXBadDrawable 0x0" on X11 otherwise.

Note: the chosen implementation to ignore GLUT calls silently appears
to be compatible with GLUT (3.7) whereas FreeGLUT 3.0 would issue error
messages and exit. The latter could be implemented as well but would
be much more work.
2023-10-07 17:14:11 +02:00
Matthias Melcher
f3eae58c52 Draw parent window backdrop on Fl_Tabs (#718) 2023-09-29 14:12:39 +02:00
Matthias Melcher
71b8e77935
FLUID: adds greatly enhanced Shell Commands (#774)
The user can add an arbitrary number of highly configurable 
shell commands through the setting panel. The commands can
be saved as user preferences, inside the .fl file, or exported
to an external file. Shell scripts can be limited to individual 
platforms, can have shortcut keys, etc. .

* documentation will follow
* support to call `fltk-config` will follow
2023-09-26 16:01:03 +02:00
Matthias Melcher
0a2f05a2fe FLUID: Fixes regression #777
Wrote wrong path in #inlude statement under certain
conditions. Also removed 'snap' tag if not needed.
2023-09-26 00:29:26 +02:00
Albrecht Schlosser
226a4ea784 Fix potential invalid stack variable access in test code
This code was (and is still) commented out but it *would* trigger
a "stack buffer overflow" error *if* uncommented.

The new code demonstrates how a binary object (Fl_Preferences 'bed')
can be dumped to a preferences file in binary format (if activated).
2023-09-22 14:03:34 +02:00
Albrecht Schlosser
43ff6f0c32 Update dependencies 2023-09-22 14:03:34 +02:00
Albrecht Schlosser
ede381c005 Fix Visual Studio shared library build
Todo: fluid-shared can't (yet) be built agains the shared fltk lib
  because of some linker errors. Needs investigation.

Note: fluid-shared is basically a test program to demonstrate linking
  against the shared FLTK libs but doesn't work yet using VS (MSVC).
  This is no problem for the functionality.
2023-09-12 23:18:46 +02:00
Albrecht Schlosser
e44a988c4a Fix unittest object file list in test/Makefile (#683) 2023-09-08 15:30:06 +02:00
Matthias Melcher
6bb5a81cee Adds some convenience methods.
fl_filename_absolute can no generate a path using arbitrary source paths.
Fl_Menu_ adds find_item_with_user_data and find_item_with_argument
Fl_String adds find(string, start)
2023-09-05 14:45:57 +02:00
Matthias Melcher
5e8adebac2 Adds compact buttons feature to create keypads.
See test/buttons for an example.
2023-09-03 00:09:40 +02:00
Matthias Melcher
92ac709b7e Adds safe versions of fl_filename_*, returning Fl_String 2023-08-26 16:48:28 +02:00
ManoloFLTK
754340e101 macOS audio is usable with XQuartz 2023-08-16 11:18:19 +02:00
ManoloFLTK
4aae2d1224 Allow build of sudoku app with macOS + XQuartz 2023-08-16 10:27:41 +02:00
Matthias Melcher
e8b378302c Undoing previous changes 2023-08-15 22:59:07 +02:00
Matthias Melcher
3b093e895b Lot's of changes, must rethink UI. 2023-08-15 17:09:51 +02:00
Matthias Melcher
af22676abf Missing includes 2023-08-15 17:09:51 +02:00
Matthias Melcher
0de186e614 Sudoku into smaller pieces. 2023-08-15 17:09:51 +02:00
Matthias Melcher
a1b55385e3 Random testing and fixing. 2023-08-15 17:09:51 +02:00
Matthias Melcher
d27188198a Removed unused code 2023-08-15 17:09:51 +02:00
Matthias Melcher
0c8083a06d Adding generator 2023-08-15 17:09:51 +02:00
Matthias Melcher
10d9010ed9
Improved, yet compatible, widget callback system using macros (#729)
* adds FL/fl_callback.macros.H
* adds FL_FUNCTION_CALLBACK_n(widget, function, [type, data])
* adds FL_METHOD_CALLBACK_n(widget, class, instance, method, [type, data])
* adds FL_INLINE_CALLBACK_n(widget, [type, name, data], callback_body)
* adds `examples/callback`
* full documentation
2023-08-15 11:36:58 +02:00
Matthias Melcher
5e484524c8 Fl_Tabs now supports horizontal mouse wheel events. 2023-08-13 14:32:41 +02:00
Albrecht Schlosser
5bcd6ca8f2 Revert "#733 partial: Adds rotation gesture event on MacOS"
This reverts commit 3049e6394a
as agreed upon in GitHub Issue #733.
2023-08-05 16:37:38 +02:00
Matthias Melcher
3049e6394a #733 partial: Adds rotation gesture event on MacOS 2023-08-05 12:19:42 +02:00
Albrecht Schlosser
4ec02555ef Fix missing (new) source file in fluid and dependencies
New file: Fl_Button_Type.cxx
2023-07-19 23:42:50 +02:00
Matthias Melcher
e8eccde8db FLUID: RTTI improvements, 'is_a90' now const, apply RTTI 2023-07-19 20:42:08 +02:00
Matthias Melcher
5d69828ed0 FLUID: fixes all overlapping widgets in all .fl files
Also fixes an issue with multiple use of the same variable
for different types of i18n.
2023-07-14 23:42:17 +02:00
Albrecht Schlosser
03913f32e0 Display mouse button state in test/handle_events.cxx demo
See fltk.general, thread "Is handling simultaneous Left-click and
  Right-click drags supported?" from Jul 12, 2023

Status: FL_DRAG operation is terminated when one mouse button is
  released, even if more than one button is actually down. Subsequent
  mouse movement is reported as FL_MOVE rather than FL_DRAG, this is
  under investigation.
2023-07-12 19:32:02 +02:00
ManoloFLTK
4fb18ffbdd Fix "Provide --without-fluid configure option" - cont'd (#725) 2023-05-10 14:41:48 +02:00
ManoloFLTK
fe0fcecd61 Fix "Provide --without-fluid configure option " (#725)
Add new --disable-fluid configure option.
2023-05-09 16:19:12 +02:00
Albrecht Schlosser
ac7b55d8bb Fix some but not all memory leaks in test/utf8 demo
Note: Fl_Input::value() copies the string to an internal buffer,
  fl_strdup() before value() is not necessary.
2023-05-08 16:26:07 +02:00
ManoloFLTK
4768ebaf8b test/utf8: improve use of Fl::set_fonts(const char *) across platforms 2023-04-14 08:58:16 +02:00
Albrecht Schlosser
4769e0085d Fix more compiler warnings (comma at end of enum)
These warnings are benign but ... I fixed them nevertheless.
2023-04-13 22:55:18 +02:00
ManoloFLTK
00b82b287c Add usage example of Fl_Window::cursor(const Fl_RGB_Image *, int, int) 2023-04-08 21:23:43 +02:00
Albrecht Schlosser
510ba8e46d Fix test/demo for X11 on macOS (e.g. XQuartz)
This modification became necessary since "__APPLE__" is no longer
undefined by the build system when X11 is used on macOS.
2023-03-22 20:29:23 +01:00
Matthias Melcher
5c482f9d9b
Fix and update alignment #346 (#701)
* interactive layout alignment rewritten
* interface for new alignment rules
* new alignment dialog box
* user defined layout rules added
* layout rules can be stored in projects, settings, and external files
* Valgrind verification
2023-03-18 17:33:27 +01:00
Albrecht Schlosser
0f41797b7a Cairo: introduce Fl::cairo_flush() in FLTK API
Flushing the Cairo context is necessary on Windows to make Cairo
drawings appear on the device (screen). This new method makes it easy
for user code to do this correctly after using Cairo drawings.

- add Fl::cairo_flush(cairo_t *)
- document Fl::cairo_flush(cairo_t *)
- reformat Cairo doxygen docs and code (partially)
- use the new method in Fl_Cairo_Window
- use the new method in test/cairo_test.cxx
- other minor (text) changes in test/cairo_test.cxx
- add test/cairo_test to the demo menu (test/demo.menu)
2023-03-14 19:51:34 +01:00
Albrecht Schlosser
af4789077f Simplify the previous Cairo drawing fix (#694)
The Cairo context 'cc' should be used directly rather than calling
'Fl::cairo_cc()' again.

Sorry for the noise.
2023-03-12 16:20:54 +01:00
Albrecht Schlosser
6e407cb169 Fix Cairo drawing in test/cairo_test demo for Windows (#694)
On the Windows platform Cairo drawings must be flushed explicitly.
This is done in Fl_Cairo_Window after calling the draw callback but
it was neither done nor documented in test/cairo_test.cxx when using
another type of Window with its overloaded draw() method, i.e. when
FLTK was configured with --enable-cairoext or CMake OPTION_CAIROEXT.

Note: user code must either explicitly flush the Cairo drawings as
done here or destroy the Cairo context which is not done in this demo
because the Cairo context should be kept alive.
2023-03-12 16:01:58 +01:00
Albrecht Schlosser
0f3b5ded8f Fix dependencies, typos, trailing whitespace, and formatting
No code changes.
2023-03-09 18:28:37 +01:00
Albrecht Schlosser
5175192755 CMake: build shared libs with OPTION_CAIROEXT (issue #250)
- remove separate libfltk_cairo to avoid cyclic dependencies, but
- keep a dummy libfltk_cairo in 1.4.0 for backwards compatibility
- move cairo/Fl_Cairo.cxx to src/Fl_Cairo.cxx
- add preliminary Cairo support for Visual Studio (MSVC)

Static linking is not affected by this change, but users building
with hand-made Makefiles will have to remove libfltk_cairo starting
with FLTK 1.4.0. The dummy library can be linked for backwards
compatibility but it will be removed later (in 1.4.x or 1.5.0).

The shared FLTK library libfltk.{so|dylib|dll|..} depends on libcairo
if and only if FLTK is built with one of the Cairo options. This has
always been the case for OPTION_CAIROEXT but is now also true if only
OPTION_CAIRO is selected, i.e. FLTK programs linked with a Cairo
enabled shared FLTK library will also be linked with libcairo. The same
is true for configure options --enable-cairo and --enable-cairoext,
respectively.

Preliminary Cairo support for MSVC now detects a Cairo installation
using the CMake variable FLTK_CAIRO_DIR which must be set by the user.
Note that this feature is temporary and may be changed in the future
for a better and more comfortable version.
2023-03-09 17:34:05 +01:00
Matthias Melcher
13cd927ab4
Add Fl_String to Fl_Preferences (#687) 2023-02-25 22:44:39 +01:00
Albrecht Schlosser
70bdf69279 Move animated gif images to the test/images folder
... to make them accessible to the help_dialog test if built with CMake.
2023-02-23 19:28:27 +01:00
Matthias Melcher
9f87af8ad9
Fl_String refactoring and extension (#683)
- add true unittest and Fl_String testing
- interface and printout are similar to gtest
  without requiring external linkage.
  just run `unittest --core`.
- new Fl_String API
- extended API to fl_input_str and fl_password_str
- co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
2023-02-23 15:42:05 +01:00
ManoloFLTK
18597e4f6c Avoid "#undef __APPLE__" preprocessor directive 2023-02-07 07:17:23 +01:00
Matthias Melcher
1aa6c4fed8
Fix position() methods that shadow Fl_Widget::position()
* `FL_DEPRECATED` macro to mark `position()` method that shadow `Fl_Widget::position()` #69 (#666)
2023-02-02 20:54:19 +01:00
ManoloFLTK
6276822e9e Allow cmake -DOPTION_APPLE_X11=On without -U__APPLE__ 2023-02-02 18:48:24 +01:00
Albrecht Schlosser
4e75549e7b Update dependencies and fix whitespace errors
- replace tabs with spaces
- remove trailing whitespace
2023-02-02 17:09:14 +01:00
Matthias Melcher
179771acd2
Fixing FLUID file corruption from issue #653 (#662)
Removing all globals in file writer (#653 )
Fix some static analyser complaints
Valgrind: handle width==0 in GfxDrivers on Wayland and X11
Don't use `Fl_Input_::static_value`, it accesses previous
buffer that may be deleted
Project file write encapsulated, removing globals
Encapsulating project file reader, removing states in glbals
Project i/o increased source code readability
2023-01-26 15:23:43 +01:00
wcout
2ddfd9d949
Animated GIF support (Fl_Anim_GIF_Image class) (#375) 2023-01-21 17:27:58 +01:00