PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: DataObject.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight 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 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLGUI_DATAOBJECT_H__ 00024 #define __PLGUI_DATAOBJECT_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/String/String.h> 00032 #include <PLCore/Container/Array.h> 00033 #include "PLGui/PLGui.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLGui { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Classes ] 00044 //[-------------------------------------------------------] 00045 /** 00046 * @brief 00047 * Represents a data object, use e.g. for the clipboard and drag&drop events 00048 */ 00049 class DataObject { 00050 00051 00052 //[-------------------------------------------------------] 00053 //[ Public functions ] 00054 //[-------------------------------------------------------] 00055 public: 00056 /** 00057 * @brief 00058 * Constructor 00059 */ 00060 PLGUI_API DataObject(); 00061 00062 /** 00063 * @brief 00064 * Constructor 00065 * 00066 * @param[in] sString 00067 * String 00068 */ 00069 PLGUI_API DataObject(const PLCore::String &sString); 00070 00071 /** 00072 * @brief 00073 * Constructor 00074 * 00075 * @param[in] lstFiles 00076 * List of file names 00077 */ 00078 PLGUI_API DataObject(const PLCore::Container<PLCore::String> &lstFiles); 00079 00080 /** 00081 * @brief 00082 * Constructor 00083 * 00084 * @param[in] nValue 00085 * Data value 00086 */ 00087 PLGUI_API DataObject(PLCore::uint32 nValue); 00088 00089 /** 00090 * @brief 00091 * Constructor 00092 * 00093 * @param[in] pData 00094 * Data buffer 00095 * @param[in] nSize 00096 * Size of data buffer 00097 */ 00098 PLGUI_API DataObject(PLCore::uint8 *pData, PLCore::uint32 nSize); 00099 00100 /** 00101 * @brief 00102 * Copy constructor 00103 * 00104 * @param[in] cOther 00105 * Data object 00106 */ 00107 PLGUI_API DataObject(const DataObject &cOther); 00108 00109 /** 00110 * @brief 00111 * Destructor 00112 */ 00113 PLGUI_API ~DataObject(); 00114 00115 /** 00116 * @brief 00117 * Comparison operator 00118 * 00119 * @param[in] cOther 00120 * Data object 00121 * 00122 * @return 00123 * 'true' if equal, else 'false' 00124 */ 00125 PLGUI_API bool operator ==(const DataObject &cOther) const; 00126 00127 /** 00128 * @brief 00129 * Assignment operator 00130 * 00131 * @param[in] cOther 00132 * Data object 00133 * 00134 * @return 00135 * Reference to this object 00136 */ 00137 PLGUI_API DataObject &operator =(const DataObject &cOther); 00138 00139 /** 00140 * @brief 00141 * Get data type 00142 * 00143 * @return 00144 * Data type 00145 */ 00146 PLGUI_API EDataType GetType() const; 00147 00148 /** 00149 * @brief 00150 * Get string data 00151 * 00152 * @return 00153 * String, empty string if data type is other than DataString 00154 */ 00155 PLGUI_API PLCore::String GetString() const; 00156 00157 /** 00158 * @brief 00159 * Set string data 00160 * 00161 * @param[in] sString 00162 * String 00163 */ 00164 PLGUI_API void Set(const PLCore::String &sString); 00165 00166 /** 00167 * @brief 00168 * Get file names 00169 * 00170 * @return 00171 * List of file names, empty list if data type is other than DataFiles 00172 */ 00173 PLGUI_API const PLCore::Container<PLCore::String> &GetFiles() const; 00174 00175 /** 00176 * @brief 00177 * Set file names 00178 * 00179 * @param[in] lstFiles 00180 * List of file names 00181 */ 00182 PLGUI_API void Set(const PLCore::Container<PLCore::String> &lstFiles); 00183 00184 /** 00185 * @brief 00186 * Get custom data 00187 * 00188 * @return 00189 * Data value, 0 if data type is other than DataCustom 00190 */ 00191 PLGUI_API PLCore::uint32 GetValue() const; 00192 00193 /** 00194 * @brief 00195 * Set custom data 00196 * 00197 * @param[in] nValue 00198 * Data value 00199 */ 00200 PLGUI_API void Set(PLCore::uint32 nValue); 00201 00202 /** 00203 * @brief 00204 * Get binary data size 00205 * 00206 * @return 00207 * Size of custom data, 0 if data type is other than DataBinary 00208 */ 00209 PLGUI_API PLCore::uint32 GetBinarySize() const; 00210 00211 /** 00212 * @brief 00213 * Get binary data 00214 * 00215 * @return 00216 * Data pointer, a null pointer if data type is other than DataBinary 00217 */ 00218 PLGUI_API PLCore::uint8 *GetBinaryData() const; 00219 00220 /** 00221 * @brief 00222 * Set binary data 00223 * 00224 * @param[in] pData 00225 * Data buffer 00226 * @param[in] nSize 00227 * Size of data buffer 00228 * 00229 * @remarks 00230 * A new buffer of the given size will be allocated and the data will be copied to that buffer. 00231 * The class takes care of deleting the allocated memory later. 00232 */ 00233 PLGUI_API void Set(PLCore::uint8 *pData, PLCore::uint32 nSize); 00234 00235 /** 00236 * @brief 00237 * Clear data 00238 */ 00239 PLGUI_API void Clear(); 00240 00241 00242 //[-------------------------------------------------------] 00243 //[ Private data ] 00244 //[-------------------------------------------------------] 00245 private: 00246 EDataType m_nDataType; /**< Data type */ 00247 PLCore::String m_sString; /**< String data */ 00248 PLCore::Array<PLCore::String> m_lstFiles; /**< List of file names */ 00249 PLCore::uint32 m_nValue; /**< Custom data */ 00250 PLCore::uint8 *m_pData; /**< Binary data buffer */ 00251 PLCore::uint32 m_nDataSize; /**< Binary data buffer size */ 00252 00253 00254 }; 00255 00256 00257 //[-------------------------------------------------------] 00258 //[ Namespace ] 00259 //[-------------------------------------------------------] 00260 } // PLGui 00261 00262 00263 #endif // __PLGUI_DATAOBJECT_H__
|