/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file MFXDynamicLabel.h14/// @author Mirko Barthauer15/// @date 31.03.202316///17// Text label with dynamic multi-line text (inserts line breaks on the fly)18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>2324#include "fxheader.h"252627/// @brief A list item which allows for custom coloring28class MFXDynamicLabel : public FXLabel {29/// @brief FOX declaration30FXDECLARE(MFXDynamicLabel)3132public:33/// @brief enum for events34enum {35MID_LABEL_WIDTHCHANGE,36};3738/// @brief Construct label with given text and icon39MFXDynamicLabel(FXComposite* p, const FXString& text, FXIcon* ic = 0, FXuint opts = LABEL_NORMAL, FXint x = 0, FXint y = 0, FXint w = 0, FXint h = 0, FXint pl = DEFAULT_PAD, FXint pr = DEFAULT_PAD, FXint pt = DEFAULT_PAD, FXint pb = DEFAULT_PAD, std::string indent = "- ");4041virtual ~MFXDynamicLabel() {};4243/// @brief overload text label updates to store the original string as backup for when width changes again44void setText(const FXString& text);4546/// @brief overload to be informed when the label text has to be reformatted due to width changes47long onUpdate(FXObject* sender, FXSelector, void*);4849/// @brief overload position to be informed when the parent has done the layout50void position(FXint x, FXint y, FXint w, FXint h);5152FXint getDefaultHeight();5354protected:55/// @brief fox needs this56MFXDynamicLabel();5758private:59/// @brief compute indentation60void computeIndentation();6162/// @brief reformat line breaks63void reformatLineBreaks(const int curWidth);6465/// @brief original string66std::string myOriginalString;6768/// @brief indent string69std::string myIndentString;7071/// @brief indent72int myIndent;7374/// @brief previous width75int myPreviousWidth;7677/// @brief Invalidated copy constructor.78MFXDynamicLabel(const MFXDynamicLabel&) = delete;7980/// @brief Invalidated assignment operator.81MFXDynamicLabel& operator=(const MFXDynamicLabel&) = delete;82};838485