Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXListItemIcon.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-2023 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//
19/****************************************************************************/
20
21/* =========================================================================
22 * included modules
23 * ======================================================================= */
24
25#include "MFXListItemIcon.h"
26
27
28#define SIDE_SPACING 6 // Left or right spacing between items
29#define ICON_SPACING 4 // Spacing between icon and label (2 + 2)
30#define ICON_SIZE 16
31
32// ===========================================================================
33// FOX callback mapping
34// ===========================================================================
35
36// Object implementation
37FXIMPLEMENT(MFXListItemIcon, FXListItem, nullptr, 0)
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
43MFXListItemIcon::MFXListItemIcon(const FXString& text, FXIcon* ic, FXColor backGroundColor, void* ptr):
44 FXListItem(text, ic, ptr),
45 myBackGroundColor(backGroundColor) {
46}
47
48
49void
50MFXListItemIcon::draw(const FXList* myList, FXDC& dc, FXint xx, FXint yy, FXint ww, FXint hh) {
51 FXFont* font = myList->getFont();
52 FXint ih = 0, th = 0;
53 ih = ICON_SIZE;
54 if (!label.empty()) {
55 th = font->getFontHeight();
56 }
57 if (isSelected()) {
58 dc.setForeground(myList->getSelBackColor());
59 } else {
60 dc.setForeground(myBackGroundColor); // FIXME maybe paint background in onPaint?
61 }
62 dc.fillRectangle(xx, yy, ww, hh);
63 if (hasFocus()) {
64 dc.drawFocusRectangle(xx + 1, yy + 1, ww - 2, hh - 2);
65 }
66 xx += SIDE_SPACING / 2;
67 if (icon) {
68 dc.drawIcon(icon, xx, yy + (hh - ih) / 2);
69 }
70 xx += ICON_SPACING + ICON_SIZE;
71 if (!label.empty()) {
72 dc.setFont(font);
73 if (!isEnabled()) {
74 dc.setForeground(makeShadowColor(myList->getBackColor()));
75 } else if (isSelected()) {
76 dc.setForeground(myList->getSelTextColor());
77 } else {
78 dc.setForeground(myList->getTextColor());
79 }
80 dc.drawText(xx, yy + (hh - th) / 2 + font->getFontAscent(), label);
81 }
82}
83
84const FXColor&
88
89
91 FXListItem("", nullptr),
92 myBackGroundColor(FXRGB(0, 0, 0)) {
93}
#define ICON_SPACING
#define ICON_SIZE
#define SIDE_SPACING
A list item which allows for custom coloring.
void draw(const FXList *list, FXDC &dc, FXint x, FXint y, FXint w, FXint h)
draw MFXListItemIcon
MFXListItemIcon()
fox need this
const FXColor & getBackGroundColor() const
get background color
FXColor myBackGroundColor
backGround color