From 0e570fb6729ff6b97249256c2c9d5f3aa58c7bb4 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 4 Jan 2026 15:50:49 +0100 Subject: Add C++11 Fl_Valuator::format API. This is helpful for writing language wrapper, in this particular case for PyFLTK. --- src/Fl_Color_Chooser.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Fl_Color_Chooser.cxx') diff --git a/src/Fl_Color_Chooser.cxx b/src/Fl_Color_Chooser.cxx index 209f4b45b..341a51347 100644 --- a/src/Fl_Color_Chooser.cxx +++ b/src/Fl_Color_Chooser.cxx @@ -1,7 +1,7 @@ // // Color chooser for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2023 by Bill Spitzak and others. +// Copyright 1998-2026 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -32,6 +32,7 @@ // The "hue box" can be a circle or rectilinear. // You get a circle by defining this: #define CIRCLE 1 + // And the "hue box" can auto-update when the value changes // you get this by defining this: #define UPDATE_HUE_BOX 1 @@ -98,11 +99,21 @@ static const Fl_Menu_Item mode_menu[] = { }; #ifndef FL_DOXYGEN + int Flcc_Value_Input::format(char* buf) { Fl_Color_Chooser* c = (Fl_Color_Chooser*)parent(); if (c->mode() == M_HEX) return snprintf(buf, 5,"0x%02X", int(value())); else return Fl_Valuator::format(buf); } + +// Note: although Flcc_Value_Input is marked private in the header files, +// it nevertheless is publicly accessible, so implement this here just in case. +std::string Flcc_Value_Input::format_str() { + char buffer[129]; + int size = format(buffer); + return std::string(buffer, size); +} + #endif // !FL_DOXYGEN void Fl_Color_Chooser::set_valuators() { -- cgit v1.2.3