• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_Canvas.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_CANVAS_H__
00024 #define __MYGUI_CANVAS_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Widget.h"
00028 #include "MyGUI_ITexture.h"
00029 
00030 namespace MyGUI
00031 {
00032 
00037     class MYGUI_EXPORT Canvas :
00038         public Widget
00039     {
00040         MYGUI_RTTI_DERIVED( Canvas );
00041 
00042     public:
00043         Canvas();
00044 
00045         struct Event
00046         {
00047             Event( bool _textureChanged, bool _widgetResized, bool _requested ) :
00048                 textureChanged( _textureChanged ),
00049                 widgetResized( _widgetResized ),
00050                 requested( _requested )
00051             {
00052             }
00053 
00054             bool textureChanged;
00055             bool widgetResized;
00056 
00058             bool requested;
00059         };
00060 
00061         typedef delegates::CDelegate1<CanvasPtr> EventInfo_Canvas;
00062         typedef delegates::CDelegate2<CanvasPtr, Event> EventInfo_CanvasEvent;
00063 
00064         //FIXME
00069         enum TextureResizeMode
00070         {
00071             //
00072             TRM_PT_CONST_SIZE, 
00073             TRM_PT_VIEW_REQUESTED, 
00074             TRM_PT_VIEW_ALL 
00075         };
00076 
00077     public:
00078 
00080         void createTexture( TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
00081 
00083         void createTexture( int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
00084 
00086         void createTexture( const IntSize& _size, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
00087 
00089         void destroyTexture();
00090 
00092         void updateTexture();
00093 
00095         void* lock(TextureUsage _usage = TextureUsage::Write);
00096 
00098         void unlock();
00099 
00101         bool isLocked() const { return mTexture->isLocked(); }
00102 
00104         int getTextureRealWidth() const { return (int) mTexture->getWidth(); }
00105 
00107         int getTextureRealHeight() const { return (int) mTexture->getHeight(); }
00108 
00110         IntSize getTextureRealSize() const { return IntSize( getTextureRealWidth(), getTextureRealHeight() ); }
00111 
00113         int getTextureSrcWidth() const { return mReqTexSize.width; }
00114 
00116         int getTextureSrcHeight() const { return mReqTexSize.height; }
00117 
00119         IntSize getTextureSrcSize() const { return mReqTexSize; }
00120 
00122         PixelFormat getTextureFormat() const { return mTexture->getFormat(); }
00123 
00125         const std::string& getTextureName() const { return mTexture->getName(); }
00126 
00128         virtual void setSize(const IntSize& _value);
00130         virtual void setCoord(const IntCoord& _value);
00131 
00133         void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
00135         void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
00136 
00138         TextureResizeMode getResizeMode() const { return mTexResizeMode; }
00139 
00141         void setResizeMode( TextureResizeMode _set ) { mTexResizeMode = _set; }
00142 
00144         bool isTextureSrcSize() const;
00145 
00147         bool isTextureCreated() const { return mTexture != nullptr; }
00148 
00150         bool isTextureManaged() const { return mTexManaged; }
00151 
00153         ITexture* getTexture() { return mTexture; }
00154 
00156         void setTextureManaged( bool _value ) { mTexManaged = _value; }
00157 
00159         static TextureUsage getDefaultTextureUsage() { return TextureUsage::Stream | TextureUsage::Write; }
00160 
00162         static PixelFormat getDefaultTextureFormat() { return PixelFormat::R8G8B8A8; }
00163 
00164     /*event:*/
00169         EventInfo_Canvas eventPreTextureChanges;
00170 
00176         EventInfo_CanvasEvent requestUpdateCanvas;
00177 
00178     /*internal:*/
00179         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00180 
00181     protected:
00182         virtual ~Canvas();
00183 
00185         void _destroyTexture( bool _sendEvent );
00186 
00188         void validate( int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format ) const;
00189 
00191         void createExactTexture( int _width, int _height, TextureUsage _usage, PixelFormat _format );
00192 
00194         bool checkCreate( int _width, int _height ) const;
00195 
00197         void resize( const IntSize& _size );
00198 
00200         void correctUV();
00201 
00203         void baseChangeWidgetSkin( ResourceSkin* _info );
00204 
00206         void initialiseWidgetSkin( ResourceSkin* _info );
00207 
00209         void shutdownWidgetSkin();
00210 
00212         void frameAdvise( bool _advise );
00213 
00215         void frameEntered( float _time );
00216 
00217     protected:
00219         ITexture* mTexture;
00220 
00222         IntSize mReqTexSize;
00223 
00225         std::string mGenTexName;
00226 
00228         TextureResizeMode mTexResizeMode;
00229 
00231         uint8* mTexData;
00232 
00234         bool mTexManaged;
00235 
00237         bool mFrameAdvise;
00238 
00239     };
00240 
00241 } // namespace MyGUI
00242 
00243 #endif // __MYGUI_CANVAS_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1