MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_IMAGE_BOX_H__ 00023 #define __MYGUI_IMAGE_BOX_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Widget.h" 00027 #include "MyGUI_ResourceImageSet.h" 00028 #include "MyGUI_ImageInfo.h" 00029 00030 namespace MyGUI 00031 { 00032 00033 class MYGUI_EXPORT ImageBox : 00034 public Widget 00035 { 00036 MYGUI_RTTI_DERIVED( ImageBox ) 00037 00038 public: 00039 ImageBox(); 00040 00041 //------------------------------------------------------------------------------// 00042 // The simple interface 00043 //------------------------------------------------------------------------------// 00044 00045 /* Set texture and size of image _tile 00046 @param _texture file name or texture name 00047 @param _coord - part of texture where we take tiles 00048 @param _tile size 00049 */ 00050 void setImageInfo(const std::string& _texture, const IntCoord& _coord, const IntSize& _tile); 00051 00052 /* Set texture 00053 @param _texture file name or texture name 00054 */ 00055 void setImageTexture(const std::string& _value); 00056 00058 void setImageRect(const IntRect& _value); 00059 00061 void setImageCoord(const IntCoord& _value); 00062 00064 void setImageTile(const IntSize& _value); 00065 00078 void setImageIndex(size_t _index); 00080 size_t getImageIndex() const; 00081 00082 //------------------------------------------------------------------------------// 00083 // The expanded interface 00084 //------------------------------------------------------------------------------// 00085 00087 size_t getItemCount() const; 00088 00090 void setItemSelect(size_t _index); 00092 size_t getItemSelect() const; 00094 void resetItemSelect(); 00095 00097 void insertItem(size_t _index, const IntCoord& _item); 00099 void addItem(const IntCoord& _item); 00101 void setItem(size_t _index, const IntCoord& _item); 00102 00104 void deleteItem(size_t _index); 00106 void deleteAllItems(); 00107 00108 // работа с фреймами анимированных индексов 00113 void addItemFrame(size_t _index, const IntCoord& _item); 00114 00120 void insertItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item); 00121 00126 void addItemFrameDublicate(size_t _index, size_t _indexSourceFrame); 00127 00133 void insertItemFrameDublicate(size_t _index, size_t _indexFrame, size_t _indexSourceFrame); 00134 00140 void setItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item); 00141 00146 void deleteItemFrame(size_t _index, size_t _indexFrame); 00147 00151 void deleteAllItemFrames(size_t _index); 00152 00157 void setItemFrameRate(size_t _index, float _rate); 00158 00162 float getItemFrameRate(size_t _index); 00163 00164 //------------------------------------------------------------------------------// 00165 // The interface with support of resources 00166 //------------------------------------------------------------------------------// 00167 00172 bool setItemResource(const std::string& _name); 00173 00175 void setItemGroup(const std::string& _value); 00177 void setItemName(const std::string& _value); 00178 00182 void setItemResourcePtr(ResourceImageSetPtr _resource); 00184 void setItemResourceInfo(const ImageIndexInfo& _info); 00185 00187 ResourceImageSetPtr getItemResource() const; 00189 void setItemResourceInfo(ResourceImageSetPtr _resource, const std::string& _group, const std::string& _name); 00190 00191 protected: 00192 virtual void shutdownOverride(); 00193 00194 virtual void setPropertyOverride(const std::string& _key, const std::string& _value); 00195 00196 private: 00197 void frameEntered(float _frame); 00198 00199 void recalcIndexes(); 00200 void updateSelectIndex(size_t _index); 00201 00202 void frameAdvise(bool _advise); 00203 00204 void _setUVSet(const FloatRect& _rect); 00205 00206 private: 00207 // кусок в текстуре наших картинок 00208 IntRect mRectImage; 00209 // размер одной картинки 00210 IntSize mSizeTile; 00211 // размер текстуры 00212 IntSize mSizeTexture; 00213 // текущая картинка 00214 size_t mIndexSelect; 00215 00216 VectorImages mItems; 00217 00218 bool mFrameAdvise; 00219 float mCurrentTime; 00220 size_t mCurrentFrame; 00221 00222 ResourceImageSetPtr mResource; 00223 std::string mItemName; 00224 std::string mItemGroup; 00225 std::string mCurrentTextureName; 00226 }; 00227 00228 } // namespace MyGUI 00229 00230 #endif // __MYGUI_IMAGE_BOX_H__