Structures.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifdef _MSC_VER
  8. #pragma warning( disable : 4244 )
  9. #pragma warning( disable : 4251 )
  10. #endif
  11. #ifndef GWEN_STRUCTURES_H
  12. #define GWEN_STRUCTURES_H
  13. #include "Gwen/Exports.h"
  14. #include <string>
  15. namespace Gwen
  16. {
  17. namespace Controls
  18. {
  19. class Base;
  20. class Canvas;
  21. }
  22. namespace CursorType
  23. {
  24. static const unsigned char Normal = 0;
  25. static const unsigned char Beam = 1;
  26. static const unsigned char SizeNS = 2;
  27. static const unsigned char SizeWE = 3;
  28. static const unsigned char SizeNWSE = 4;
  29. static const unsigned char SizeNESW = 5;
  30. static const unsigned char SizeAll = 6;
  31. static const unsigned char No = 7;
  32. static const unsigned char Wait = 8;
  33. static const unsigned char Finger = 9;
  34. static const unsigned char Count = 10;
  35. }
  36. typedef std::wstring UnicodeString;
  37. typedef std::string String;
  38. typedef wchar_t UnicodeChar; // Portability??
  39. struct GWEN_EXPORT Margin
  40. {
  41. Margin( int left = 0, int top = 0, int right = 0, int bottom = 0 )
  42. {
  43. this->top = top;
  44. this->bottom = bottom;
  45. this->left = left;
  46. this->right = right;
  47. }
  48. int top, bottom, left, right;
  49. };
  50. typedef Margin Padding;
  51. struct GWEN_EXPORT Rect
  52. {
  53. Rect( int x = 0, int y = 0, int w = 0, int h = 0 )
  54. {
  55. this->x = x;
  56. this->y = y;
  57. this->w = w;
  58. this->h = h;
  59. }
  60. int x, y, w, h;
  61. };
  62. struct GWEN_EXPORT Point
  63. {
  64. Point(int x = 0, int y = 0)
  65. {
  66. this->x = x;
  67. this->y = y;
  68. }
  69. int x, y;
  70. };
  71. struct GWEN_EXPORT HSV
  72. {
  73. float h;
  74. float s;
  75. float v;
  76. };
  77. struct GWEN_EXPORT Color
  78. {
  79. Color( unsigned char r = 255, unsigned char g = 255, unsigned char b = 255, unsigned char a = 255 )
  80. {
  81. this->r = r;
  82. this->g = g;
  83. this->b = b;
  84. this->a = a;
  85. }
  86. void operator = ( Color c )
  87. {
  88. this->r = c.r;
  89. this->g = c.g;
  90. this->b = c.b;
  91. this->a = c.a;
  92. }
  93. void operator += ( Color c )
  94. {
  95. this->r += c.r;
  96. this->g += c.g;
  97. this->b += c.b;
  98. this->a += c.a;
  99. }
  100. void operator -= ( Color c )
  101. {
  102. this->r -= c.r;
  103. this->g -= c.g;
  104. this->b -= c.b;
  105. this->a -= c.a;
  106. }
  107. void operator *= ( float f )
  108. {
  109. this->r *= f;
  110. this->g *= f;
  111. this->b *= f;
  112. this->a *= f;
  113. }
  114. Color operator *( float f )
  115. {
  116. return Color(
  117. (float)this->r*f,
  118. (float)this->g*f,
  119. (float)this->b*f,
  120. (float)this->a*f
  121. );
  122. }
  123. Color operator - ( Color c )
  124. {
  125. return Color(
  126. this->r - c.r,
  127. this->g - c.g,
  128. this->b - c.b,
  129. this->a - c.a
  130. );
  131. }
  132. Color operator + ( Color c )
  133. {
  134. return Color(
  135. this->r + c.r,
  136. this->g + c.g,
  137. this->b + c.b,
  138. this->a + c.a
  139. );
  140. }
  141. bool operator ==( const Color& c ) const
  142. {
  143. return c.r==r && c.g==g && c.b==b && c.a==a;
  144. }
  145. unsigned char r, g, b, a;
  146. };
  147. namespace DragAndDrop
  148. {
  149. struct GWEN_EXPORT Package
  150. {
  151. Package()
  152. {
  153. userdata = NULL;
  154. draggable = false;
  155. drawcontrol = NULL;
  156. holdoffset = Gwen::Point( 0, 0 );
  157. }
  158. String name;
  159. void* userdata;
  160. bool draggable;
  161. Gwen::Controls::Base* drawcontrol;
  162. Gwen::Point holdoffset;
  163. };
  164. }
  165. }
  166. #endif