Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2004-2026 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 : /****************************************************************************/
14 : /// @file MFXTreeListDynamic.h
15 : /// @author Pablo Alvarez Lopez
16 : /// @date Feb 2021
17 : ///
18 : //
19 : /****************************************************************************/
20 :
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <vector>
25 : #include <utils/gui/div/GUIDesigns.h>
26 :
27 : #include "fxheader.h"
28 :
29 : // ===========================================================================
30 : // class definitions
31 : // ===========================================================================
32 :
33 : class FXTreeItemDynamic : public FXTreeItem {
34 :
35 : public:
36 : /// @brief Constructor
37 : FXTreeItemDynamic(const FXString& text, FXIcon* oi = nullptr, FXIcon* ci = nullptr, void* ptr = nullptr);
38 :
39 : /// Change text color
40 : void setTextColor(FXColor clr);
41 :
42 : protected:
43 : /// @brief draw tree item
44 : void draw(const FXTreeList* list, FXDC& dc, FXint xx, FXint yy, FXint, FXint hh) const;
45 :
46 : private:
47 : /// @brief set text color
48 : FXColor myTextColor = GUIDesignTextColorBlack;
49 : };
50 :
51 : /// @brief MFXTreeListDynamic
52 : class MFXTreeListDynamic : protected FXTreeList {
53 : /// @brief FOX-declaration
54 0 : FXDECLARE(MFXTreeListDynamic)
55 :
56 : public:
57 : /// @brief Constructor
58 : MFXTreeListDynamic(FXComposite* p, FXObject* tgt, FXSelector sel, FXuint opts);
59 :
60 : /// @brief Show MFXTreeListDynamic
61 : void show();
62 :
63 : /// @brief Hide MFXTreeListDynamic
64 : void hide();
65 :
66 : /// @brief update
67 : void update();
68 :
69 : /// @brief clear items
70 : void clearItems();
71 :
72 : /// @brief get num items
73 : FXint getNumItems();
74 :
75 : /// @brief getSelected item index
76 : FXint getSelectedIndex();
77 :
78 : /// @brief prepend item with given text and icon
79 : FXTreeItem* prependItem(FXTreeItem* father, const FXString& text, FXIcon* oi, FXColor tColor = GUIDesignTextColorBlack);
80 :
81 : /// @brief append item with given text and icon
82 : FXTreeItem* appendItem(FXTreeItem* father, const FXString& text, FXIcon* oi, FXColor tColor = GUIDesignTextColorBlack);
83 :
84 : /// @brief get FXWindows associated with this MFXTreeListDynamic
85 : FXWindow* getFXWindow();
86 :
87 : /// @brief Get item at x,y, if any
88 : FXTreeItem* getItemAt(FXint x, FXint y) const;
89 :
90 : /// @brief Get item
91 : FXTreeItemDynamic* getItem(FXint index) const;
92 :
93 : /// @brief reset selected item
94 : void resetSelectedItem();
95 :
96 : /// @name FOX calls
97 : /// @{
98 : long onLeftBtnPress(FXObject*, FXSelector, void*);
99 : /// @}
100 :
101 : protected:
102 : /// @brief default constructor
103 : MFXTreeListDynamic();
104 :
105 : /// @brief list with current FXTreeItemDynamic elements
106 : std::vector<FXTreeItemDynamic*> myFXTreeItemDynamicItems;
107 :
108 : /// @brief selected item
109 : FXint mySelectedItem = -1;
110 :
111 : private:
112 : /// @brief Invalidated copy constructor.
113 : MFXTreeListDynamic(const MFXTreeListDynamic&) = delete;
114 :
115 : /// @brief Invalidated assignment operator.
116 : MFXTreeListDynamic& operator=(const MFXTreeListDynamic&) = delete;
117 : };
|