MyGUI 3.0.1

MyGUI_StaticImage.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_STATIC_IMAGE_H__
00024 #define __MYGUI_STATIC_IMAGE_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Widget.h"
00028 #include "MyGUI_ResourceImageSet.h"
00029 #include "MyGUI_ImageInfo.h"
00030 #include "MyGUI_Guid.h"
00031 
00032 namespace MyGUI
00033 {
00034 
00035     class MYGUI_EXPORT StaticImage :
00036         public Widget
00037     {
00038         MYGUI_RTTI_DERIVED( StaticImage )
00039 
00040     public:
00041         StaticImage();
00042 
00043         //------------------------------------------------------------------------------//
00044         // The simple interface
00045         //------------------------------------------------------------------------------//
00046 
00047         /* Set texture and size of image _tile
00048             @param _texture file name or texture name
00049             @param _coord - part of texture where we take tiles
00050             @param _tile size
00051         */
00052         void setImageInfo(const std::string& _texture, const IntCoord& _coord, const IntSize& _tile);
00053 
00054         /* Set texture
00055             @param _texture file name or texture name
00056         */
00057         void setImageTexture(const std::string& _value);
00058 
00060         void setImageRect(const IntRect& _value);
00061 
00063         void setImageCoord(const IntCoord& _value);
00064 
00066         void setImageTile(const IntSize& _value);
00067 
00080         void setImageIndex(size_t _index);
00082         size_t getImageIndex();
00083 
00084         //------------------------------------------------------------------------------//
00085         // The expanded interface
00086         //------------------------------------------------------------------------------//
00087 
00089         size_t getItemCount() const { return mItems.size(); }
00090 
00092         void setItemSelect(size_t _index);
00094         size_t getItemSelect() { return mIndexSelect; }
00096         void resetItemSelect() { setItemSelect(ITEM_NONE); }
00097 
00099         void insertItem(size_t _index, const IntCoord& _item);
00101         void addItem(const IntCoord& _item) { insertItem(ITEM_NONE, _item); }
00103         void setItem(size_t _index, const IntCoord& _item);
00104 
00106         void deleteItem(size_t _index);
00108         void deleteAllItems();
00109 
00110         // работа с фреймами анимированных индексов
00115         void addItemFrame(size_t _index, const IntCoord& _item);
00116 
00122         void insertItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
00123 
00128         void addItemFrameDublicate(size_t _index, size_t _indexSourceFrame);
00129 
00135         void insertItemFrameDublicate(size_t _index, size_t _indexFrame, size_t _indexSourceFrame);
00136 
00142         void setItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
00143 
00148         void deleteItemFrame(size_t _index, size_t _indexFrame);
00149 
00153         void deleteAllItemFrames(size_t _index);
00154 
00159         void setItemFrameRate(size_t _index, float _rate);
00160 
00164         float getItemFrameRate(size_t _index);
00165 
00166         //------------------------------------------------------------------------------//
00167         // The interface with support of resources
00168         //------------------------------------------------------------------------------//
00169 
00174         bool setItemResource(const Guid& _id);
00175 
00180         bool setItemResource(const std::string& _name);
00181 
00183         void setItemGroup(const std::string& _value);
00185         void setItemName(const std::string& _value);
00186 
00190         void setItemResourcePtr(ResourceImageSetPtr _resource);
00192         void setItemResourceInfo(const ImageIndexInfo& _info);
00193 
00195         ResourceImageSetPtr getItemResource() { return mResource; }
00197         void setItemResourceInfo(ResourceImageSetPtr _resource, const std::string& _group, const std::string& _name);
00198 
00200         virtual void setProperty(const std::string& _key, const std::string& _value);
00201 
00202     /*internal:*/
00203         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00204 
00205     protected:
00206         virtual ~StaticImage();
00207 
00208         void baseChangeWidgetSkin(ResourceSkin* _info);
00209 
00210     private:
00211         void initialiseWidgetSkin(ResourceSkin* _info);
00212         void shutdownWidgetSkin();
00213 
00214         void frameEntered(float _frame);
00215 
00216         void recalcIndexes();
00217         void updateSelectIndex(size_t _index);
00218 
00219         void frameAdvise(bool _advise);
00220 
00221     private:
00222         // кусок в текстуре наших картинок
00223         IntRect mRectImage;
00224         // размер одной картинки
00225         IntSize mSizeTile;
00226         // размер текстуры
00227         IntSize mSizeTexture;
00228         // текущая картинка
00229         size_t mIndexSelect;
00230 
00231         VectorImages mItems;
00232 
00233         bool mFrameAdvise;
00234         float mCurrentTime;
00235         size_t mCurrentFrame;
00236 
00237         ResourceImageSetPtr mResource;
00238         std::string mItemName;
00239         std::string mItemGroup;
00240         std::string mCurrentTextureName;
00241 
00242     };
00243 
00244 } // namespace MyGUI
00245 
00246 #endif // __MYGUI_STATIC_IMAGE_H__
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines