Advertisement
dcomicboy

ui.h

Apr 3rd, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. /**********************************
  2. | Author : XForce |
  3. | Website : xforce.square7.ch |
  4. | |
  5. ***********************************/
  6.  
  7. #include <vector>
  8. #include <string>
  9. #include <sstream>
  10. #include <d3d9.h>
  11. #include <d3dx9.h>
  12. //#include "drawfuncs.h"
  13. #pragma comment(lib, "d3d9.lib")
  14. #pragma comment(lib , "d3dx9.lib")
  15. //extern ID3DXFont *xfont;
  16.  
  17. #undef SAFE_RELEASE
  18. #define SAFE_RELEASE( d ) \
  19. if ( d ) \
  20. { \
  21. d->Release(); \
  22. d = NULL; \
  23. }
  24.  
  25. extern LPD3DXLINE g_pLine;
  26.  
  27. enum types
  28. {
  29. Window,
  30. Button,
  31. Textbox,
  32. ListBox,
  33. ComboBox,
  34. NumericUpDown,
  35. };
  36.  
  37.  
  38. enum WindowState
  39. {
  40. Hide,
  41. Normal,
  42. Active,
  43. };
  44.  
  45.  
  46. struct XListBoxItem
  47. {
  48. std::string name;
  49. std::string info;
  50. int selected;
  51. };
  52.  
  53. class XControl
  54. {
  55. public:
  56. int x;
  57. int y;
  58. int h;
  59. int w;
  60. POINT window;
  61. virtual void Render(LPDIRECT3DDEVICE9 Device);
  62. std::string title;
  63. types type;
  64. int id;
  65. int active;
  66.  
  67. void (*clickevent)(XControl* sender,types type); //Only for buttons
  68. };
  69.  
  70. class XTextBox : public XControl
  71. {
  72. public:
  73. XTextBox();
  74. XTextBox(int x,int y,int h,int w,int id);
  75. std::string getText();
  76. //void Render();
  77. int caretPos;
  78. int caretPosScreen;
  79. int caretTick;
  80. int showPosbegin;
  81. int showPosend;
  82. int charw;
  83. bool showCaret;
  84. DWORD ltick;
  85. std::string textbuffer;
  86. void HandleInput(int nCode, WPARAM wParam, LPARAM lParam);
  87. void Render(LPDIRECT3DDEVICE9 Device);
  88. };
  89.  
  90.  
  91. class XButton : public XControl
  92. {
  93.  
  94. public:
  95. XButton();
  96. XButton(int x,int y,int h,int w, std::string title,void (*func)(XButton* sender),int id);
  97. XButton(RECT rct,std::string title,void* func,int id);
  98.  
  99.  
  100. void Render(LPDIRECT3DDEVICE9 Device);
  101. void(*clickevent)(XButton* sender);
  102. int getstate(); // 1 - Normal 2 - Hide 3 - Closed
  103. void Release();
  104. };
  105.  
  106. class XNumericUpDown : public XControl
  107. {
  108.  
  109. public:
  110. XNumericUpDown();
  111. XNumericUpDown(int x,int y,int h,int w, std::string title,int id);
  112. XNumericUpDown(RECT rct,std::string title,void* func,int id);
  113.  
  114.  
  115. void Render(LPDIRECT3DDEVICE9 Device);
  116. int mouse;
  117. float step;
  118. float value;
  119. float max;
  120. float min;
  121. int getstate(); // 1 - Normal 2 - Hide 3 - Closed
  122. void Release();
  123. };
  124.  
  125.  
  126.  
  127. class XListBox : public XControl
  128. {
  129. public:
  130. XListBox();
  131. XListBox(int x,int y,int h,int w, std::string title,int id);
  132. int selected;
  133. std::vector<XListBoxItem> items;
  134. int out;
  135. int slidermouse;
  136. int slidery;
  137. void AddItem(XListBoxItem item);
  138. void RemoveItem(XListBoxItem item);
  139. void Render(LPDIRECT3DDEVICE9 Device);
  140. XListBoxItem GetSelectedItem();
  141. };
  142.  
  143.  
  144. class XWindow
  145. {
  146.  
  147. public:
  148. int x,y,h,w;
  149. std::string title;
  150. XWindow();
  151. XWindow(int x,int y,int h,int w, std::string title,int id);
  152. XWindow(RECT rct,std::string title ,int id);
  153. D3DCOLOR textcolor;
  154. int id;
  155. WindowState state;
  156. bool fadeout;
  157.  
  158. std::vector<XControl*> controls;
  159. void AddControl(XControl* control);
  160. void RemoveControl(XControl* control);
  161. void Render(LPDIRECT3DDEVICE9 Device);
  162. int getstate(); // 1 - Normal 2 - Hide 3 - Closed
  163. void Release();
  164. };
  165.  
  166.  
  167.  
  168. class XGUI
  169. {
  170. public:
  171. XGUI();
  172. std::vector<XWindow*> windows;
  173. void AddWindow(XWindow* window);
  174. void RemoveWindow(XWindow* window);
  175. void Release();
  176. bool disabled;
  177. void Render(LPDIRECT3DDEVICE9 pDevice/*,D3DVIEWPORT9 viewport,ID3DXFont* xfont*/);
  178. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement