hgegui.h
上传用户:jnfxsk
上传日期:2022-06-16
资源大小:3675k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. /*
  2. ** Haaf's Game Engine 1.7
  3. ** Copyright (C) 2003-2007, Relish Games
  4. ** hge.relishgames.com
  5. **
  6. ** hgeGUI helper classes header
  7. */
  8. #ifndef HGEGUI_H
  9. #define HGEGUI_H
  10. #include "hge.h"
  11. #include "hgesprite.h"
  12. #include "hgerect.h"
  13. #define HGEGUI_NONAVKEYS 0
  14. #define HGEGUI_LEFTRIGHT 1
  15. #define HGEGUI_UPDOWN 2
  16. #define HGEGUI_CYCLED 4
  17. class hgeGUI;
  18. /*
  19. ** hgeGUIObject
  20. */
  21. class hgeGUIObject
  22. {
  23. public:
  24. hgeGUIObject() { hge=hgeCreate(HGE_VERSION); color=0xFFFFFFFF; }
  25. virtual ~hgeGUIObject() { hge->Release(); }
  26. virtual void Render() = 0;
  27. virtual void Update(float dt) {}
  28. virtual void Enter() {}
  29. virtual void Leave() {}
  30. virtual void Reset() {}
  31. virtual bool IsDone() { return true; }
  32. virtual void Focus(bool bFocused) {}
  33. virtual void MouseOver(bool bOver) {}
  34. virtual bool MouseMove(float x, float y) { return false; }
  35. virtual bool MouseLButton(bool bDown) { return false; }
  36. virtual bool MouseRButton(bool bDown) { return false; }
  37. virtual bool MouseWheel(int nNotches) { return false; }
  38. virtual bool KeyClick(int key, int chr) { return false; }
  39. virtual void SetColor(DWORD _color) { color=_color; }
  40. int id;
  41. bool bStatic;
  42. bool bVisible;
  43. bool bEnabled;
  44. hgeRect rect;
  45. DWORD color;
  46. hgeGUI *gui;
  47. hgeGUIObject *next;
  48. hgeGUIObject *prev;
  49. protected:
  50. hgeGUIObject(const hgeGUIObject &go);
  51. hgeGUIObject& operator= (const hgeGUIObject &go);
  52. static HGE *hge;
  53. };
  54. /*
  55. ** hgeGUI
  56. */
  57. class hgeGUI
  58. {
  59. public:
  60. hgeGUI();
  61. ~hgeGUI();
  62. void AddCtrl(hgeGUIObject *ctrl);
  63. void DelCtrl(int id);
  64. hgeGUIObject* GetCtrl(int id) const;
  65. void MoveCtrl(int id, float x, float y);
  66. void ShowCtrl(int id, bool bVisible);
  67. void EnableCtrl(int id, bool bEnabled);
  68. void SetNavMode(int mode);
  69. void SetCursor(hgeSprite *spr);
  70. void SetColor(DWORD color);
  71. void SetFocus(int id);
  72. int GetFocus() const;
  73. void Enter();
  74. void Leave();
  75. void Reset();
  76. void Move(float dx, float dy);
  77. int Update(float dt);
  78. void Render();
  79. private:
  80. hgeGUI(const hgeGUI &);
  81. hgeGUI& operator= (const hgeGUI&);
  82. bool ProcessCtrl(hgeGUIObject *ctrl);
  83. static HGE *hge;
  84. hgeGUIObject *ctrls;
  85. hgeGUIObject *ctrlLock;
  86. hgeGUIObject *ctrlFocus;
  87. hgeGUIObject *ctrlOver;
  88. int navmode;
  89. int nEnterLeave;
  90. hgeSprite *sprCursor;
  91. float mx,my;
  92. int nWheel;
  93. bool bLPressed, bLReleased;
  94. bool bRPressed, bRReleased;
  95. };
  96. #endif