MyGUI  3.2.0
MyGUI_Canvas.h
Go to the documentation of this file.
1 
6 /*
7  This file is part of MyGUI.
8 
9  MyGUI is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  MyGUI is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_CANVAS_H__
23 #define __MYGUI_CANVAS_H__
24 
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Widget.h"
27 #include "MyGUI_ITexture.h"
28 
29 namespace MyGUI
30 {
31 
37  public Widget,
39  {
41 
42  public:
43  Canvas();
44 
45  struct Event
46  {
47  Event( bool _textureChanged, bool _widgetResized, bool _requested ) :
48  textureChanged( _textureChanged ),
49  widgetResized( _widgetResized ),
50  requested( _requested )
51  {
52  }
53 
56 
58  bool requested;
59  };
60 
63 
64  //FIXME
70  {
71  //
74  TRM_PT_VIEW_ALL
75  };
76 
77  public:
79  void createTexture(TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
80 
82  void createTexture(int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
83 
85  void createTexture(const IntSize& _size, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
86 
88  void destroyTexture();
89 
91  void updateTexture();
92 
94  void* lock(TextureUsage _usage = TextureUsage::Write);
95 
97  void unlock();
98 
100  bool isLocked() const;
101 
103  int getTextureRealWidth() const;
104 
106  int getTextureRealHeight() const;
107 
109  IntSize getTextureRealSize() const;
110 
112  int getTextureSrcWidth() const;
113 
115  int getTextureSrcHeight() const;
116 
118  IntSize getTextureSrcSize() const;
119 
121  PixelFormat getTextureFormat() const;
122 
124  const std::string& getTextureName() const;
125 
127  virtual void setSize(const IntSize& _value);
129  virtual void setCoord(const IntCoord& _value);
130 
132  void setSize(int _width, int _height);
134  void setCoord(int _left, int _top, int _width, int _height);
135 
137  TextureResizeMode getResizeMode() const;
138 
140  void setResizeMode(TextureResizeMode _value);
141 
143  bool isTextureSrcSize() const;
144 
146  bool isTextureCreated() const;
147 
149  bool isTextureManaged() const;
150 
152  ITexture* getTexture() const;
153 
155  void setTextureManaged(bool _value);
156 
158  static TextureUsage getDefaultTextureUsage();
159 
161  static PixelFormat getDefaultTextureFormat();
162 
163  /*events:*/
169 
176 
177  protected:
178  virtual void shutdownOverride();
179  virtual void initialiseOverride();
180 
182  void _destroyTexture(bool _sendEvent);
183 
185  void validate(int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format) const;
186 
188  void createExactTexture(int _width, int _height, TextureUsage _usage, PixelFormat _format);
189 
191  bool checkCreate(int _width, int _height) const;
192 
194  void resize(const IntSize& _size);
195 
197  void correctUV();
198 
200  void frameAdvise(bool _advise);
201 
203  void frameEntered(float _time);
204 
205  virtual void textureInvalidate(ITexture* _texture);
206 
207  void _setUVSet(const FloatRect& _rect);
208 
209  protected:
212 
215 
217  std::string mGenTexName;
218 
221 
224 
227 
230 
232  };
233 
234 } // namespace MyGUI
235 
236 #endif // __MYGUI_CANVAS_H__
EventHandle_CanvasPtrEvent requestUpdateCanvas
Definition: MyGUI_Canvas.h:175
bool mFrameAdvise
For updating once per frame. True state means updating before next frame starts.
Definition: MyGUI_Canvas.h:229
EventHandle_CanvasPtr eventPreTextureChanges
Definition: MyGUI_Canvas.h:168
ITexture * mTexture
Current texture.
Definition: MyGUI_Canvas.h:211
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
#define MYGUI_EXPORT
delegates::CMultiDelegate1< Canvas * > EventHandle_CanvasPtr
Definition: MyGUI_Canvas.h:61
IntSize mReqTexSize
Requested bu user sizes.
Definition: MyGUI_Canvas.h:214
delegates::CDelegate2< Canvas *, Event > EventHandle_CanvasPtrEvent
Definition: MyGUI_Canvas.h:62
TextureResizeMode mTexResizeMode
Texture resize mode.
Definition: MyGUI_Canvas.h:220
Event(bool _textureChanged, bool _widgetResized, bool _requested)
Definition: MyGUI_Canvas.h:47
bool mTexManaged
true if we own the texture (can delete it or replace by another instance), otherwise false ...
Definition: MyGUI_Canvas.h:226
bool requested
This update was caused by calling updateTexture();.
Definition: MyGUI_Canvas.h:58
unsigned char uint8
Definition: MyGUI_Types.h:61
std::string mGenTexName
Generated texture name.
Definition: MyGUI_Canvas.h:217
bool mInvalidateData
Definition: MyGUI_Canvas.h:231
uint8 * mTexData
Saved pointer from last calling lock.
Definition: MyGUI_Canvas.h:223
Texture doesn't resizes and fills all widget space.
Definition: MyGUI_Canvas.h:73