Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MFXDynamicLabel.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Text label with dynamic multi-line text (inserts line breaks on the fly)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
24
25#include "fxheader.h"
26
27
29class MFXDynamicLabel : public FXLabel {
31 FXDECLARE(MFXDynamicLabel)
32
33public:
35 enum {
37 };
38
40 MFXDynamicLabel(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 = "- ");
41
42 virtual ~MFXDynamicLabel() {};
43
45 void setText(const FXString& text);
46
48 long onUpdate(FXObject* sender, FXSelector, void*);
49
51 void position(FXint x, FXint y, FXint w, FXint h);
52
53 FXint getDefaultHeight();
54
55protected:
58
59private:
61 void computeIndentation();
62
64 void reformatLineBreaks(const int curWidth);
65
67 std::string myOriginalString;
68
70 std::string myIndentString;
71
74
77
80
83};
A list item which allows for custom coloring.
void reformatLineBreaks(const int curWidth)
reformat line breaks
MFXDynamicLabel()
fox needs this
int myPreviousWidth
previous width
MFXDynamicLabel & operator=(const MFXDynamicLabel &)=delete
Invalidated assignment operator.
void setText(const FXString &text)
overload text label updates to store the original string as backup for when width changes again
void position(FXint x, FXint y, FXint w, FXint h)
overload position to be informed when the parent has done the layout
virtual ~MFXDynamicLabel()
MFXDynamicLabel(const MFXDynamicLabel &)=delete
Invalidated copy constructor.
void computeIndentation()
compute indentation
long onUpdate(FXObject *sender, FXSelector, void *)
overload to be informed when the label text has to be reformatted due to width changes
std::string myOriginalString
original string
std::string myIndentString
indent string