Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXListIcon.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
26
27#include "MFXListIcon.h"
28#include "MFXListItemIcon.h"
29
30
31#define LINE_SPACING 4 // Line spacing between items
32#define ICON_SIZE 16
33
34// ===========================================================================
35// FOX callback mapping
36// ===========================================================================
37
38FXDEFMAP(MFXListIcon) MFXListIconMap[] = {
39 FXMAPFUNC(SEL_PAINT, 0, MFXListIcon::onPaint),
40};
41
42// Object implementation
43FXIMPLEMENT(MFXListIcon, FXList, MFXListIconMap, ARRAYNUMBER(MFXListIconMap))
44
45// ===========================================================================
46// member method definitions
47// ===========================================================================
48
49MFXListIcon::MFXListIcon(FXComposite* p, FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h):
50 FXList(p, tgt, sel, opts, x, y, w, h) {
51}
52
53
54FXint
56 if (visible) {
57 return visible * (LINE_SPACING + FXMAX(font->getFontHeight(), ICON_SIZE));
58 } else {
59 return FXScrollArea::getDefaultHeight();
60 }
61}
62
63
64long
65MFXListIcon::onPaint(FXObject*, FXSelector, void* ptr) {
66 FXEvent* event = (FXEvent*)ptr;
67 FXDCWindow dc(this, event);
68 FXint i, y, h;
69 // Paint items
70 y = pos_y;
71 for (i = 0; i < items.no(); i++) {
72 const auto listIcon = dynamic_cast<MFXListItemIcon*>(items[i]);
73 if (listIcon) {
74 h = listIcon->getHeight(this);
75 if (event->rect.y <= (y + h) && y < (event->rect.y + event->rect.h)) {
76 listIcon->draw(this, dc, pos_x, y, FXMAX(listWidth, viewport_w), h);
77 }
78 y += h;
79 }
80 }
81 // Paint blank area below items
82 if (y < (event->rect.y + event->rect.h)) {
83 dc.setForeground(backColor);
84 dc.fillRectangle(event->rect.x, y, event->rect.w, event->rect.y + event->rect.h - y);
85 }
86 return 1;
87}
88
90 FXList() {
91}
#define ICON_SIZE
#define LINE_SPACING
FXDEFMAP(MFXListIcon) MFXListIconMap[]
A list item which allows for custom coloring.
Definition MFXListIcon.h:28
FXint getDefaultHeight()
Get default height.
MFXListIcon()
fox need this
long onPaint(FXObject *, FXSelector, void *)
Draw item list.
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