Commit Graph

222 Commits

Author SHA1 Message Date
Albrecht Schlosser bc63ea7629 CMake: improve linking OpenGL3 example programs (#959)
- Remove find_library(LIB_GLEW ...) from 'resources.cmake'

- Use the variable FLTK_GLEW_DIR to "find" a user supplied GLEW library
  for OpenGL3 example programs (examples/OpenGL3*.cxx).
  Both static and shared libs (DLLs) are supported, but the static
  library is preferred to avoid DLL dependencies.

- Define preprocessor macro 'GLEW_STATIC' by CMake compile definitions
  if and only if the static glew library (glew32s) was found and linked.
  The previous code defined 'GLEW_STATIC' unconditionally in the source
  code which led to undefined references if a shared lib (DLL) was used.
2024-05-13 15:19:27 +02:00
Albrecht Schlosser 38e1d6b099 Fix Visual Studio compiler warnings, make output visible...
on Windows w/o a console device ("DOS"/Debug window) if OpenGL3 is
not available.
2024-05-05 19:33:28 +02:00
Albrecht Schlosser 036e0334dc Simplify examples/CMakeLists.txt (libcairo linkage)
Fl_Cairo_Window is included in fltk::fltk and libcairo is linked
implicitly if FLTK was built with Cairo support.
2024-03-17 03:16:19 +01:00
Albrecht Schlosser 4ea058da0a Update examples/CMakeLists.txt to modern CMake
Also: set build requirement of OpenGL3 tests to C++11 to enable
building in C++98 mode (if the compiler allows C++11).

Note: this may be removed in 1.5.0 when FLTK requires C++11 anyway.
2024-02-11 16:06:17 +01:00
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
Albrecht Schlosser 829cac52c6 Fix numeric keyboard example program
examples/howto-remap-numpad-keyboard-keys.cxx:

Substitute Fl::event_key() as well which is required for some input
widgets - maybe only on some platforms (seemed to work on X11 but
not on Wayland).

Also: fix typos and whitespace.
2024-01-06 17:56:04 +01:00
Albrecht Schlosser 1d73c0195c Improve docs and add two new Fl_Menu_Item methods (#875)
This addresses some issues pointed out by GitHub Issue #875.

Documentation lacked details about Fl_Multi_Label assignment and
correct memory handling.

The new methods
 - Fl_Menu_Item::image_label(const Fl_Image *) and
 - Fl_Menu_Item::multi_label(const Fl_Multi_Label *)
provide a cleaner interface to assign images and Fl_Multi_Label's
to menu items.

examples/howto-menu-with-images.cxx: carify some issues, fix leak,
  and use new Fl_Menu_Item::multi_label(const Fl_Multi_Label *).
2023-12-23 20:08:18 +01:00
Greg Ercolano bdbd3497d4 STR#3283: Add new Fl_Table right-click popup menu example 2023-12-16 00:07:33 -08:00
Greg Ercolano bbafcafbe1 fix window titles for table examples 2023-12-14 14:43:46 -08: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
Greg Ercolano 7c95aa7c79 Change Fl_Terminal default color() 0x0 -> FL_BLACK 2023-11-20 13:33:08 -08:00
erco77 6842a43a31
Fl_Terminal widget (#800)
Pull Fl_Terminal widget from Greg's fork
2023-11-14 07:01:52 -08: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
Albrecht Schlosser 5c7ad00e07 Improve Fl_Grid example code
Add 'grid->end();' although it's redundant in this specific example.
2023-10-19 14:22:58 +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
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 e8eccde8db FLUID: RTTI improvements, 'is_a90' now const, apply RTTI 2023-07-19 20:42:08 +02:00
Albrecht Schlosser 8b1ec4c531 Fix Visual Studio (MSVC) compiler warnings 2023-03-09 17:47:51 +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
Albrecht Schlosser 880fc26857 Fix clang compiler warning
Warning was: "implicit conversion from 'int' to 'float' changes value
  from 2147483647 to 2147483648"

Not a big deal in this context, but anyway.
2023-02-07 16:17:54 +01:00
Albrecht Schlosser fdc614ea25 Fix examples/.gitignore (add missing files) 2023-02-05 19:52:53 +01:00
Albrecht Schlosser 130a1c21a7 Fix deprecated warnings in examples/table* demo programs
Also: adjust comments, update copyright year
2023-02-04 19:21:53 +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
wcout 2ddfd9d949
Animated GIF support (Fl_Anim_GIF_Image class) (#375) 2023-01-21 17:27:58 +01:00
Albrecht Schlosser 420042aefb Improve examples/chart-simple demo program
Make sure that the first chart entry is not zero because this wouldn't
show the first part of FL_SPECIALPIE_CHART separated from the circle.
2023-01-16 00:30:32 +01:00
Albrecht Schlosser a29c0e36fd Add Fl_Scheme_Choice to examples/tree-custom-draw-items
- add Fl_Scheme_Choice widget for quick scheme selection
- fix label alignment of selection box
- set selection_color()
- set selectbox()
- make the tree the resizable() of the window
2023-01-12 19:21:09 +01:00
Matthias Melcher 44c874b731
Use `FL_OVERRIDE` for all overridden virtual methods (#611)
FL_OVERRIDE is defined as `override` for C++11 and higher
FL_OVERRIDE is defined as `override` for VisualC 2015 and newer
Don't interfere with Fl_Widget::override()
2022-12-30 19:14:36 +01:00
Albrecht Schlosser 44a2547394
Rename some Fl_Flex methods for FLTK compliance (#594)
Change some method names to comply with FLTK style as discussed
in fltk.coredev, thread "Fl_Flex method name question".

* Rename Fl_Flex::margins(...) to Fl_Flex::margin(...)
  (use singular form for all margin related methods)

* Remove Fl_Flex::setSize() and isSetSize() "backwards compatibility" methods

* Rename Fl_Flex::set_size(...) to fixed(...)

Note: the latter affects existing (pre-release) fluid (.fl) files: you may
  want to edit and replace "set_size_tuples" with "fixed_size_tuples"
2022-12-15 16:46:40 +01:00
Albrecht Schlosser f375ff9689 CMake: fix building examples w/o test programs
As reported in fltk.coredev in thread
  "CMAKE build with build examples. On and test OFF fails"

$ cmake .. -D FLTK_BUILD_EXAMPLES=ON -D FLTK_BUILD_TEST=OFF

failed with: Unknown CMake command "FLTK_RUN_FLUID".
2022-11-19 11:55:45 +01:00
Albrecht Schlosser c570bd8f96 Fix trailing whitespace 2022-11-01 20:06:22 +01:00
ManoloFLTK 6732044a07 Fix use of several FLTK widgets above an GL scene.
The code failed with 2 or more widgets when FLTK would trigger
partial redraws of the widgets, unless the Fl_Gl_Window was FL_DAMAGE_ALL.

This commit also adds a second FLTK widget to example/OpenGL3test to
check this multiple widget situation, and fixes an error where operator ! was used
instead of ~ .
2022-10-06 08:43:09 +02:00
ManoloFLTK da66e21e1d Support of FLTK widgets in OpenGL 3 windows - cont'd.
This commit allows to switch between FL_DOUBLE / FL_SINGLE modes
in widget-containing GL3 windows.
Demo program examples/OpenGL3test is modified to show FLTK widgets
even if the platform does not support OpenGL 3.
2022-09-29 09:39:21 +02:00
ManoloFLTK c2efb0d849 macOS: support of FLTK widgets in OpenGL 3 windows - cont'd.
This code is OK under macOS 10 9 and 13.
2022-09-28 17:06:00 +02:00
ManoloFLTK 59fc60ea4c Simpler code to support FLTK widgets in macOS OpenGL 3 windows.
Also, the application-level code to add widgets to a GL3 window becomes
platform-independent.
2022-09-27 14:12:39 +02:00
ManoloFLTK 2ffd4e4f1a Replace all calls to sprintf() by calls to snprintf(). 2022-09-26 16:12:18 +02:00
ManoloFLTK 89f9671b40 Add cross-platform support for adding widgets to an OpenGL3-based Fl_Gl_Window.
Under non-macOS platforms, the key is to call glUseProgram(0); after having used OpenGL 3
which allows to then use OpenGL 1 and draw FLTK widgets over the OpenGL3 scene.

Under macOS, this is impossible because macOS GL3 contexts are not compatible
with GL1. The solution implemented here is to create an additional Fl_Gl_Window
placed above and sized as the GL3-based window, to give it a non opaque,
GL1-based context, and to put the FLTK widgets in that additional window.
2022-09-25 16:39:40 +02:00
ManoloFLTK 9c0c04c50d Use adequate #include for fl_wl_display(). 2022-09-23 08:46:26 +02:00
ManoloFLTK 6b63516890 Wayland: fix error detection during call to glewInit(). 2022-09-22 08:07:46 +02:00
Albrecht Schlosser a5b9cc888b Add option to test Fl_Flex in test/pack.cxx
This new feature demonstrates that Fl_Flex can be used (almost) as
a drop-in replacement of Fl_Pack.

Add missing file to examples/.gitignore.
2022-08-08 11:07:40 +02:00
Albrecht Schlosser e6c2503453 Add Fl_Flex demo "howto-flex-simple" to examples
This demo program uses an Fl_Flex widget with one row of buttons.
2022-08-07 18:01:59 +02:00
Albrecht Schlosser c74a482756 Make Cairo example compatible with Cairo version < 1.12 (#436) 2022-04-26 15:36:29 +02:00
Albrecht Schlosser 345e04c083 CMake: Fix OpenGL3 examples libglew link order (#226) 2022-03-09 22:38:05 +01:00
Albrecht Schlosser fbf7a347ec CMake/MinGW/MSYS2: fix building examples with libglew32 (#226)
CMake/resources.cmake: add NAMES option to find_library

examples/CMakeLists.txt: fix linking libGLEW/libglew32
2022-03-07 15:05:07 +01:00
ManoloFLTK 3718effc43 Add the Wayland platform to FLTK 1.4 2022-03-04 15:41:00 +01:00
Albrecht Schlosser 04ccc8cc46 Remove experimental platforms Android, Pico, SDL (PR #376)
... as discussed in fltk.coredev: "FLTK 1.4.0 release schedule"
https://groups.google.com/g/fltkcoredev/c/PDbHTRpXVh0/m/JqboexZ_AwAJ
2022-01-23 18:12:47 +01:00
Albrecht Schlosser cd611e3957 Remove unnecessary CMake test statement (#358)
Sorry for the noise, this statement was included in my proposed patch.
2022-01-17 15:17:17 +01:00
Greg Ercolano 196430b016 Issue #358 cont'd: Fl_Cairo_Window coord system docs
Elaborated on Fl_Cairo_Window's use of FLTK style coordinates,
    and how this differs from cairo's default native normalized
    coordinate system, and shows how to switch from one to the other.

    Also, small comment fix to the cairo example regarding the "X" color.
2022-01-16 16:59:49 -08:00
Greg Ercolano 313212b497 Adding Albrecht's CMakeLists.txt patch
Albrecht submitted this in issue 358.
    Tested the variations:

    	cmake ..		                               -- examples and cairo off
	cmake -D FLTK_BUILD_EXAMPLES=on                        -- examples on, cairo off
	cmake -D FLTK_BUILD_EXAMPLES=on -D OPTION_CAIRO=on ..  -- examples on, cairo on

    When examples are 'on', they build into the bin/examples directory.
2022-01-16 15:42:23 -08:00
Greg Ercolano 6546814a23 For issue #358 - adds examples/cairo-draw-x.cxx
Since this is the first cairo example in the examples directory,
    it necessarily involved changes to the Makefile and to fltk-config
    to properly handle the absence/existance of the cairo libs.

    TBD: Add docs to the cario widget describing coordinate system
    and how it differs from the default cairo normalized coordinate system.
2022-01-16 15:22:16 -08:00