/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2004-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 MFXBaseObject.h14/// @author Mathew Robertson15/// @author Daniel Krajzewicz16/// @author Michael Behrisch17/// @date 2004-03-1918///19//20/****************************************************************************/21#pragma once22#include <config.h>2324#include <FXHash.h>25using namespace FX;2627namespace FXEX {2829/**30* Define so that all types and all id's can go to a specific function.31* This is particularily useful if you just want to forward the event to a target32* but not specifically use the onDefault method.33*34* Note: if FXApp* is not specified, then FXApp::Instance() is used.35*/36#define FXMAPALL(func) {MKUINT(MINKEY,MINTYPE),MKUINT(MAXKEY,MAXTYPE),&func}3738/**39* Define so that we can use it to 'redirect' all unhandled events, of a specific key/ID40*/41#define FXMAPKEY(key,func) {MKUINT(key,MINTYPE),MKUINT(key,MAXTYPE),&func}424344/**45* This is a base class for ojects which can send messages to the application46*/47class /* FXAPI // patch by Daniel Krajzewicz 24.02.2004 */48MFXBaseObject : public FXObject {49FXDECLARE(MFXBaseObject)5051protected:52/// flags defined are the same as those defined in FXWindow, etc.53enum {54FLAG_ENABLED = 0x00000002, // enabled55FLAG_UPDATE = 0x00000004, // needs update56FLAG_FOCUSED = 0x00000010, // has focus57FLAG_DIRTY = 0x00000020, // dirty58FLAG_RECALC = 0x00000040, // needs recalculation59FLAG_DEFAULT = 0x00000200, // set to default60FLAG_INITIAL = 0x00000400, // set to initial value61FLAG_ACTIVE = 0x00001000, // active62FLAG_CHANGED = 0x00010000, // changed63FLAG_READONLY = 0x10000000 // read only64};6566private:67FXApp* app; // application pointer6869protected:70FXObject* target; // application target71FXSelector message; // application message72void* data; // user data73FXuint datalen; // length of user data74FXuint flags; // state flags75FXuint options; // option flags7677public:78enum {79ID_NONE = 0,80ID_DELETE = 6,81ID_DISABLE,82ID_ENABLE,83ID_SETVALUE = 17,84ID_SETINTVALUE,85ID_SETREALVALUE,86ID_SETSTRINGVALUE,87ID_SETINTRANGE,88ID_SETREALRANGE,89ID_GETINTVALUE,90ID_GETREALVALUE,91ID_GETSTRINGVALUE,92ID_XML,93ID_META,94ID_COMMENT,95ID_DOCUMENT,96ID_TAG,97ID_CONTENT,98ID_LAST99};100101public:102long onCmdEnable(FXObject*, FXSelector, void*);103long onCmdDisable(FXObject*, FXSelector, void*);104long onUpdate(FXObject*, FXSelector, void*);105106public:107/// Just supply the target and selector (de-serialisation too)108MFXBaseObject(FXObject* tgt = NULL, FXSelector sel = 0);109110/// Alternnatively, supply the app object as well111MFXBaseObject(FXApp* a, FXObject* tgt = NULL, FXSelector sel = 0);112113/// application pointer114FXApp* getApp();115116/// get the target117FXObject* getTarget() {118return target;119}120121/// set the target122void setTarget(FXObject* tgt) {123target = tgt;124}125126/// get the message127FXSelector getSelector() {128return message;129}130131/// set the selector132void setSelector(FXSelector sel) {133message = sel;134}135136/// get user data137void* getUserData() {138return data;139}140141/// set user data142void setUserData(void* d) {143data = d;144}145146/// get user daat length147FXuint getUserDataLen() {148return datalen;149}150151/// set the user data length152void setUserDataLen(FXuint len) {153datalen = len;154}155156/// are we enabled?157FXbool isEnabled() {158return (flags & FLAG_ENABLED) != 0;159}160161/// enable us162virtual void enable() {163flags |= FLAG_ENABLED;164}165166/// disable us167virtual void disable() {168flags &= ~FLAG_ENABLED;169}170171/// are we modifiable172virtual FXbool isReadonly() {173return (flags & FLAG_READONLY) != 0;174}175176/// set modifiable mode177virtual void setReadonly(FXbool mode = TRUE);178179/// create resource180virtual void create() {}181182/// detach resource183virtual void detach() {}184185/// destroy resource186virtual void destroy() {}187188/// save object to stream189virtual void save(FXStream& store) const;190191/// load object from stream192virtual void load(FXStream& store);193194/// dtor195virtual ~MFXBaseObject();196};197198} // namespace FXEX199200201