Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXSettingsDataTarget.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                  Settings Data Target                                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2003 by Mathew Robertson.   All Rights Reserved.                *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 ********************************************************************************/
00022 #ifndef FXSETTINGSDATATARGET_H
00023 #define FXSETTINGSDATATARGET_H
00024 
00025 #ifndef FXDATATARGET_H
00026 #include <fox/FXDataTarget.h>
00027 using namespace FX;
00028 #endif
00029 namespace FXEX {
00030 
00031 /**
00032  * An extension to FXDataTarget...
00033  *
00034  * Using this type of datatarget, we manipulate the values in the FXSettings dict directly,
00035  * such as directly updating the application registry
00036  */
00037 class FXAPI FXSettingsDataTarget : public FXDataTarget {
00038   FXDECLARE(FXSettingsDataTarget)
00039 
00040   protected:
00041     FXSettings  *settings;  // pointer to real application settings database
00042     FXString     section;
00043     FXString     key;
00044 
00045   public:
00046   long onCmdValue(FXObject*,FXSelector,void*);
00047   long onCmdOption(FXObject*,FXSelector,void*);
00048 
00049   public:
00050     /// create unassociated data target 
00051     FXSettingsDataTarget(FXObject* tgt=NULL,FXSelector sel=0):FXDataTarget(tgt,sel){}
00052 
00053     /// create FXint-associated data target
00054     FXSettingsDataTarget(FXint& value,FXObject* tgt=NULL,FXSelector sel=0):FXDataTarget(value,tgt,sel){}
00055 
00056     /// create FXuint-associated data target
00057     FXSettingsDataTarget(FXuint& value,FXObject* tgt=NULL,FXSelector sel=0):FXDataTarget(value,tgt,sel){}
00058 
00059     /// create FXdouble-associated data target
00060     FXSettingsDataTarget(FXdouble& value,FXObject* tgt=NULL,FXSelector sel=0):FXDataTarget(value,tgt,sel){}
00061 
00062     /// create FXString-associated data target
00063     FXSettingsDataTarget(FXString& value,FXObject* tgt=NULL,FXSelector sel=0):FXDataTarget(value,tgt,sel){}
00064 
00065     /// associate with FXint
00066     void connect(FXint& value);
00067 
00068     /// associate with FXuint
00069     void connect(FXuint& value);
00070 
00071     /// associate with FXdouble
00072     void connect(FXdouble& value);
00073 
00074     /// associate with FXString
00075     void connect(FXString& value);
00076 
00077     /// call this immediately after instantiation - otherwise it acts like a normal DataTarget
00078     void setSettings(FXSettings* settingsDb=NULL,const FXString& sect=NULL,const FXString& ky=NULL);
00079 
00080     /// dtor
00081     virtual ~FXSettingsDataTarget();
00082   };
00083 
00084 } // namespace FXEX
00085 #endif // FXSETTINGSDATATARGET_H