You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include <string.h>
  2. #include "coreElement.h"
  3. #include "../gui_sdl.h"
  4. sdlGraphicElement::sdlGraphicElement(int x, int y, int w, int h):m_bInitComplete(false){
  5. m_pGUI = classGUI_SDL::getInstance();
  6. setGeometry(x, y, w, h);
  7. m_bHidden = false;
  8. m_eType = GEL_NONE;
  9. m_nVisualStage = 0;
  10. m_pEnabled = true;
  11. };
  12. sdlGraphicElement::sdlGraphicElement(SDL_Rect &R):m_bInitComplete(false) {
  13. m_pGUI = classGUI_SDL::getInstance();
  14. setGeometry(R);
  15. m_bHidden = false;
  16. m_eType = GEL_NONE;
  17. m_nVisualStage = 0;
  18. m_pEnabled = true;
  19. };
  20. sdlGraphicElement::sdlGraphicElement(SDL_Rect* R):m_bInitComplete(false) {
  21. m_pGUI = classGUI_SDL::getInstance();
  22. setGeometry(R);
  23. m_bHidden = false;
  24. m_eType = GEL_NONE;
  25. m_nVisualStage = 0;
  26. m_pEnabled = true;
  27. };
  28. sdlGraphicElement::~sdlGraphicElement() {
  29. };
  30. void sdlGraphicElement::setGeometry(int x, int y, int w, int h) {
  31. m_sGeometry.x = x;
  32. m_sGeometry.y = y;
  33. m_sGeometry.w = w;
  34. m_sGeometry.h = h;
  35. m_bUpdateReq = true;
  36. };
  37. void sdlGraphicElement::setGeometry(SDL_Rect& R) {
  38. memcpy(&m_sGeometry, &R, sizeof(SDL_Rect));
  39. m_bUpdateReq = true;
  40. };
  41. void sdlGraphicElement::setGeometry(SDL_Rect* R) {
  42. memcpy(&m_sGeometry, R, sizeof(SDL_Rect));
  43. m_bUpdateReq = true;
  44. };
  45. void sdlGraphicElement::moveTo(int x, int y) {
  46. m_sGeometry.x = x;
  47. m_sGeometry.y = y;
  48. m_bUpdateReq = true;
  49. };
  50. void sdlGraphicElement::setVisibility(bool val) {
  51. m_bHidden = !val;
  52. m_bUpdateReq = true;
  53. };
  54. void DestroyTextureHeapItem(TEXTURE_HEAP_ITEM*& ptr) {
  55. if (ptr != NULL) {
  56. if (ptr->texture != NULL) {
  57. SDL_DestroyTexture(ptr->texture);
  58. };
  59. free(ptr);
  60. ptr = NULL;
  61. };
  62. };