MyGUI  3.0.1
MyGUI_Canvas.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_CANVAS_H__
24 #define __MYGUI_CANVAS_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Widget.h"
28 #include "MyGUI_ITexture.h"
29 
30 namespace MyGUI
31 {
32 
38  public Widget,
40  {
42 
43  public:
44  Canvas();
45 
46  struct Event
47  {
48  Event( bool _textureChanged, bool _widgetResized, bool _requested ) :
49  textureChanged( _textureChanged ),
50  widgetResized( _widgetResized ),
51  requested( _requested )
52  {
53  }
54 
57 
59  bool requested;
60  };
61 
64 
65  //FIXME
71  {
72  //
75  TRM_PT_VIEW_ALL
76  };
77 
78  public:
79 
81  void createTexture( TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
82 
84  void createTexture( int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
85 
87  void createTexture( const IntSize& _size, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat() );
88 
90  void destroyTexture();
91 
93  void updateTexture();
94 
96  void* lock(TextureUsage _usage = TextureUsage::Write);
97 
99  void unlock();
100 
102  bool isLocked() const { return mTexture->isLocked(); }
103 
105  int getTextureRealWidth() const { return (int) mTexture->getWidth(); }
106 
108  int getTextureRealHeight() const { return (int) mTexture->getHeight(); }
109 
111  IntSize getTextureRealSize() const { return IntSize( getTextureRealWidth(), getTextureRealHeight() ); }
112 
114  int getTextureSrcWidth() const { return mReqTexSize.width; }
115 
117  int getTextureSrcHeight() const { return mReqTexSize.height; }
118 
120  IntSize getTextureSrcSize() const { return mReqTexSize; }
121 
123  PixelFormat getTextureFormat() const { return mTexture->getFormat(); }
124 
126  const std::string& getTextureName() const { return mTexture->getName(); }
127 
129  virtual void setSize(const IntSize& _value);
131  virtual void setCoord(const IntCoord& _value);
132 
134  void setSize(int _width, int _height) { setSize(IntSize(_width, _height)); }
136  void setCoord(int _left, int _top, int _width, int _height) { setCoord(IntCoord(_left, _top, _width, _height)); }
137 
139  TextureResizeMode getResizeMode() const { return mTexResizeMode; }
140 
142  void setResizeMode( TextureResizeMode _set ) { mTexResizeMode = _set; }
143 
145  bool isTextureSrcSize() const;
146 
148  bool isTextureCreated() const { return mTexture != nullptr; }
149 
151  bool isTextureManaged() const { return mTexManaged; }
152 
154  ITexture* getTexture() { return mTexture; }
155 
157  void setTextureManaged( bool _value ) { mTexManaged = _value; }
158 
161 
164 
165  /*event:*/
171 
178 
179  /*internal:*/
180  virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
181 
182  protected:
183  virtual ~Canvas();
184 
186  void _destroyTexture( bool _sendEvent );
187 
189  void validate( int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format ) const;
190 
192  void createExactTexture( int _width, int _height, TextureUsage _usage, PixelFormat _format );
193 
195  bool checkCreate( int _width, int _height ) const;
196 
198  void resize( const IntSize& _size );
199 
201  void correctUV();
202 
204  void baseChangeWidgetSkin( ResourceSkin* _info );
205 
207  void initialiseWidgetSkin( ResourceSkin* _info );
208 
210  void shutdownWidgetSkin();
211 
213  void frameAdvise( bool _advise );
214 
216  void frameEntered( float _time );
217 
218  virtual void textureInvalidate(ITexture* _texture);
219 
220  protected:
223 
226 
228  std::string mGenTexName;
229 
232 
235 
238 
241 
242  };
243 
244 } // namespace MyGUI
245 
246 #endif // __MYGUI_CANVAS_H__