XCUI.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _XCUI_H_
  2. #define _XCUI_H_
  3. #include<string>
  4. #include<vector>
  5. using namespace std;
  6. #pragma region CommonData
  7. struct rect{
  8. int x;
  9. int y;
  10. };
  11. typedef rect point;
  12. struct xcui_commondata_t{
  13. bool flg_onshow;
  14. rect window;
  15. }xcui_commondata;
  16. #pragma endregion
  17. #pragma region XcuiBase
  18. class WidgetBase{
  19. public:
  20. string uniqueID; //Must be unique in one layer
  21. bool active;
  22. bool enable;
  23. bool visble;
  24. point pos;
  25. int _event OnLoad()={};
  26. int _event OnShow()={};
  27. int _event On
  28. virtual int DrawBuf()={};
  29. virtual void* Widgetctl(WidgetBase& src,string& info)={}; //for widget interactive
  30. };
  31. class LayerBase{
  32. public:
  33. string titleText;
  34. vector<WidgetBase> options; //option text
  35. string uniqueID; //Must be unique.
  36. int numOfStatus;
  37. int highLightedIndex; //0 < this < numOfStatus
  38. virtual void DrawMenu(); //菜单绘制,允许重载
  39. virtual void StatusMove(int status) = 0; //状态机跳转,必须提供重载
  40. virtual void beginOutPut(){}; //绘制菜单选项前输出信息,允许重载
  41. virtual void endOutPut(){}; //绘制菜单选项后输出信息,允许重载
  42. LayerBase(string _titletext, vector<string>& _options, vector<string>& _infos){
  43. titleText = titleText;
  44. options = _options;
  45. infos = _infos;
  46. numOfStatus = options.size();
  47. highLightedIndex = 0;
  48. }
  49. LayerBase(){;}
  50. };
  51. #pragma endregion
  52. void Refresh();
  53. void DrawLayer(LayerBase& layer);
  54. #endif