My Project
GUIContainer.h
1 #pragma once
2 
3 #include "GUIBase.h"
4 #include <list>
5 
6 namespace ParaEngine
7 {
8  class CGUIButton;
9  class CGUIScrollBar;
10  class CGUIEditBox;
11  struct GUITextureElement;
12 
19  class CGUIContainer: public CGUIBase
20  {
21  public:
22  enum GUI_POPUP_STYLE{
23  Popup_None=0,
24  Popup_Autohide=1,
25  Popup_Autodelete=2
26  };
27 
28  CGUIContainer();
29  virtual ~CGUIContainer();
30  ATTRIBUTE_DEFINE_CLASS(CGUIContainer);
31 
32  virtual int GetChildCount();
33 
38  virtual GUIBase_List_Type* GetChildren(){ return &m_children;};
39 
44  virtual CGUIBase* GetChildByID(int nChildID);
45 
50  virtual CGUIBase* GetChildByName(const string& name);
51 
57  void AddChild(CGUIBase* pChild, int nIndex = -1);
58 
62  virtual void DestroyChildren();
63 
68  bool SortChildrenByZOrder();
69 
73  virtual int GetZOrder()const;
74 
79  virtual void SetDepth(float fDepth);
80 
86  void SetKeyFocus(CGUIBase* control);
92  void SetMouseFocus(CGUIBase* control);
93 
99  virtual CGUIBase* GetKeyFocus(){return m_pKeyFocus;};
111  int GetScrollType();
112 
118  void SetScrollType(int etype);
119 
124  virtual bool IsScrollable();
125 
130  void SetScrollable(bool bScrollable);
131 
135  void ResetScrollbar();
136 
143  virtual CGUIBase* GetObjectAtPoint(int x,int y);
148  virtual CGUIBase* GetObjectAtPointRecursive(int x,int y);
156  //virtual HRESULT RenderMask(GUIState* pGUIState, RECT rcWindow );
157 
162  virtual void Begin(GUIState* pGUIState,float fElapsedTime);
163 
169  virtual HRESULT Render(GUIState* pGUIState ,float fElapsedTime);
170 
175  virtual void End(GUIState* pGUIState,float fElapsedTime);
176 
177  virtual bool OnFocusOut();
178  void SetFastRender(bool fastrender){m_bFastRender=fastrender;}
179  bool GetFastRender(){return m_bFastRender;}
180 
187  virtual void UpdateScroll(int nXDelta,int nYDelta);
188  virtual void UpdateRects();
195  virtual bool InvalidateRect(const RECT* lpRect);
196  void UpdateScrollSize();
203  virtual void UpdateClientRect(const CGUIPosition& pos,bool unupdate=false);
204 
205  virtual string ToScript(int option=0);
206  virtual void InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height);
207  virtual HRESULT RestoreDeviceObjects();; // device dependent
208  virtual bool MsgProc(MSG *event);
209 
210  virtual void NextKeyFocus();
211 
213  virtual bool ActivateDefaultButton();
214 
215 
217  virtual CGUIButton* GetDefaultButton();
218 
219  /* the next editbox inside this container will get focus. If no next editbox is found, this function will return false. */
220  virtual bool ActivateNextEdit(CGUIEditBox* curCtrl = nullptr);
221 
223  virtual CGUIEditBox* GetNextEdit(CGUIEditBox* curCtrl = nullptr);
224 
232  virtual GUITextureElement* GetTextureElement(const char *texturename);
233 
234  void SetScrollbarWidth(int width);
235  int GetScrollbarWidth()const{return m_nSBWidth;}
236  void Clone(IObject* pobj)const;
237  IObject *Clone()const;
238  virtual const IType* GetType()const{return m_type;}
239 
240  static void StaticInit();
241 
245  virtual void BringToFront(CGUIBase* obj);
249  virtual void SendToBack(CGUIBase* obj);
250 
254  virtual void SetVisible(bool visible);
258  virtual void SetCandrag(bool bCandrag);
268  virtual void SetTopLevel(bool value);
269  virtual bool GetTopLevel()const{return m_bIsTop;}
270 
271  //obsolete
272  virtual void SetPopUp(int popup);
273  //obsolete
274  virtual int GetPopUp()const{return m_nPopupStyle;}
275 
276  virtual void BeginUpdate(){m_bBatching=true;};
277  virtual void EndUpdate(){m_bBatching=false;};
278 
280  virtual QPoint GetCompositionPoint();
281 
283  virtual void SetCompositionPoint(const QPoint& point);
284 
288  virtual bool CanPaintOnDevice(CPaintDevice* val);
289 
295  CGUIScrollBar* GetScrollBar(int nVerticalHorizontal=0);
296 
298  int GetChildIndex(CGUIBase* pChild);
299 
300  virtual bool IsNonClientTestEnabled();
301  virtual void EnableNonClientTest(bool val);
302 
303  protected:
305  virtual CRenderTarget* CreateGetRenderTarget(bool bCreateIfNotExist = true);
306 
307  protected:
310  static const IType* m_type;
316  GUIBase_List_Type m_children;
325 
326  //vector<CGUIBase*> m_objDrawingControls;
327  //int m_nRefValue; //stores it's own reference value for stencil buffer
328  //DWORD tempRef;
329  int m_nBorder;
330  int m_nMargin;
331  int m_nSBWidth; //width of the scrollbars
332  bool m_bFastRender;//whether to speed up rendering
333  RECT m_oldRect;//the old rectangle of the scissor rectangle
334  RECT m_clientRect;//the rect that contains all children
335  QPoint m_compositionPoint;
336  int m_nPopupStyle;//obsolete
337  bool m_bIsTop;
338  bool m_bBatching;//if a Batching operation is on the way
339  bool m_bNeedCalClientRect;//if the child rect needs to be recalculate
342  friend class CGUIRoot;
343  };
344 }
Definition: GUIButton.h:10
virtual bool InvalidateRect(const RECT *lpRect)
adds a rectangle to the specified window&#39;s update region.
Definition: GUIContainer.cpp:966
IType is for type information and validating It contains type information of an object.
Definition: Type.h:75
void ResetScrollbar()
Reset the scroll bar.
Definition: GUIContainer.cpp:414
CGUIBase * m_pMouseFocus
one of its children control where the mouse located
Definition: GUIContainer.h:320
virtual CGUIBase * GetKeyFocus()
Gets the direct key focus of the current control.
Definition: GUIContainer.h:99
virtual CGUIEditBox * GetNextEdit(CGUIEditBox *curCtrl=nullptr)
get the next editbox inside this container.
Definition: GUIContainer.cpp:1296
int m_ScrollType
Scroll type.
Definition: GUIContainer.h:322
virtual void BringToFront(CGUIBase *obj)
Bring the obj to the front of z-order if the obj is child of this container.
Definition: GUIContainer.cpp:627
virtual GUIBase_List_Type * GetChildren()
Gets the control&#39;s children.
Definition: GUIContainer.h:38
CGUIScrollBar * GetScrollBar(int nVerticalHorizontal=0)
get the vertical or horizontal scroll bar.
Definition: GUIContainer.cpp:133
mostly associated with a CGUIContainer m_objResource->m_objArtwork->DrawingRects[0]: track rectangle;...
Definition: GUIScrollBar.h:21
bool m_bScrollable
whether it can automatically scroll
Definition: GUIContainer.h:309
Definition: EventBinding.h:22
a render target scene object.
Definition: RenderTarget.h:16
different physics engine has different winding order.
Definition: EventBinding.h:32
CGUIBase * m_pKeyFocus
one of its children control which has Key focus
Definition: GUIContainer.h:318
virtual void SetDepth(float fDepth)
set the 3D depth.
Definition: GUIContainer.cpp:1545
Definition: ManagedDef.h:18
virtual void SetCompositionPoint(const QPoint &point)
if set to (0,0) it will use the bounding bottom.
Definition: GUIContainer.cpp:1647
virtual void UpdateRects()
Definition: GUIContainer.cpp:993
virtual HRESULT Render(GUIState *pGUIState, float fElapsedTime)
Render function of the control.
Definition: GUIContainer.cpp:868
Definition: GUIEdit.h:17
base object for all 2D GUI objects (1) 2D GUI object are not tested against view frustum, instead it is controlled by visibility tag automatically or through user input.
Definition: GUIBase.h:54
base class for object, such as CBaseObject, IAttributeObject, GUI object.
Definition: PERef.h:287
virtual CRenderTarget * CreateGetRenderTarget(bool bCreateIfNotExist=true)
a render target will be created with the same name as this object.
Definition: GUIContainer.cpp:1579
IObject * Clone() const
Clone the object&#39;s contains and return a pointer to the newly created object.
Definition: GUIContainer.cpp:126
void SetScrollType(int etype)
Set the scroll type of the control.
Definition: GUIContainer.cpp:620
int GetScrollType()
Get the scroll type of the control.
Definition: GUIContainer.cpp:961
virtual int GetZOrder() const
z order affect the order of rendering.
Definition: GUIContainer.cpp:1540
virtual void SetVisible(bool visible)
If set invisible, the control will make itself not on top.
Definition: GUIContainer.cpp:1355
m_objResource->m_objArtwork->DrawingRects[0]: client rectangle; m_objResource->m_objArtwork->DrawingR...
Definition: GUIContainer.h:19
virtual CGUIBase * GetObjectAtPointRecursive(int x, int y)
Gets the deepest non-click-through object at the given point.
Definition: GUIContainer.cpp:1426
void SetKeyFocus(CGUIBase *control)
Set key focus of this control.
Definition: GUIContainer.cpp:452
a texture from a rectangular region of bitmap, and one additional texture color
Definition: GUIResource.h:12
It&#39;s used as parameter to Render method of each GUI object.
Definition: GUIState.h:16
virtual void UpdateClientRect(const CGUIPosition &pos, bool unupdate=false)
this function will update the client rectangle of this object.
Definition: GUIContainer.cpp:1185
virtual CGUIBase * GetMouseFocus()
Gets the direct mouse focus of the current control.
Definition: GUIContainer.h:105
Definition: enum_maker.hpp:46
Definition: ParaPoint.h:5
virtual bool MsgProc(MSG *event)
First, send the message to the scrollbar.
Definition: GUIContainer.cpp:713
virtual bool IsScrollable()
return true if it is scrollable.
Definition: GUIContainer.cpp:956
CGUIScrollBar * m_HScroll
Horizontal scrollbar.
Definition: GUIContainer.h:314
virtual CGUIBase * GetChildByName(const string &name)
get the first child node whose name is name.
Definition: GUIContainer.cpp:361
virtual CGUIBase * GetChildByID(int nChildID)
get a child node by its id
Definition: GUIContainer.cpp:349
void SetMouseFocus(CGUIBase *control)
Set mouse focus of this control.
Definition: GUIContainer.cpp:518
void SetScrollable(bool bScrollable)
set scrollable
Definition: GUIContainer.cpp:948
virtual void SetCandrag(bool bCandrag)
If set dragable, the control will make itself not on top.
Definition: GUIContainer.cpp:1363
GUIBase_List_Type m_children
child object
Definition: GUIContainer.h:316
CGUIScrollBar * m_VScroll
Vertical scrollbar.
Definition: GUIContainer.h:312
virtual void Begin(GUIState *pGUIState, float fElapsedTime)
Render a mask of the container to ensure none of its descendants is rendered outside its boundary...
Definition: GUIContainer.cpp:810
base class for a surface to paint to.
Definition: PaintDevice.h:10
bool m_bEnableNonClientTest
default to false.
Definition: GUIContainer.h:341
virtual void UpdateScroll(int nXDelta, int nYDelta)
Tell the container how many items are scrolled in both X and Y direction.
Definition: GUIContainer.cpp:1219
virtual CGUIButton * GetDefaultButton()
get the default button inside this container.
Definition: GUIContainer.cpp:1273
position of the GUI object
Definition: GUIPosition.h:34
int GetChildIndex(CGUIBase *pChild)
get the index of the given child.
Definition: GUIContainer.cpp:1557
virtual GUITextureElement * GetTextureElement(const char *texturename)
Get the texture element.
Definition: GUIContainer.cpp:1470
virtual bool CanPaintOnDevice(CPaintDevice *val)
whether this object is allowed to paint on the given device.
Definition: GUIContainer.cpp:1609
virtual bool ActivateDefaultButton()
click the default button inside this container.
Definition: GUIContainer.cpp:1261
virtual CGUIBase * GetObjectAtPoint(int x, int y)
Gets the direct object at the given point.
Definition: GUIContainer.cpp:1398
WeakPtr m_renderTarget
only used when self paint is enabled, when we will render into our own render target.
Definition: GUIContainer.h:324
virtual void End(GUIState *pGUIState, float fElapsedTime)
Do some fininsh-ups after render.
Definition: GUIContainer.cpp:845
virtual void SendToBack(CGUIBase *obj)
Send the obj to the back of z-order if the obj is child of this container.
Definition: GUIContainer.cpp:643
virtual QPoint GetCompositionPoint()
get composition point.
Definition: GUIContainer.cpp:1622
bool SortChildrenByZOrder()
Sort children by z-order.
Definition: GUIContainer.cpp:1534
void AddChild(CGUIBase *pChild, int nIndex=-1)
add a child object.
Definition: GUIContainer.cpp:373
virtual void DestroyChildren()
Clear all the control&#39;s children.
Definition: GUIContainer.cpp:323
When rendering scene, root scene and the root GUI are rendered in sequence.
Definition: GUIRoot.h:48
virtual void SetTopLevel(bool value)
Sets the container as the top-level control.
Definition: GUIContainer.cpp:659