GUIElementStyle.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. namespace BansheeEngine
  4. {
  5. public struct RectOffset
  6. {
  7. int left, right, top, bottom;
  8. };
  9. public enum GUIImagePosition
  10. {
  11. Left, Right
  12. };
  13. public enum TextHorzAlign
  14. {
  15. Left, Center, Right
  16. };
  17. public enum TextVertAlign
  18. {
  19. Top, Center, Bottom
  20. };
  21. public sealed class GUIElementStyle : ScriptObject
  22. {
  23. // Constructor for runtime use only (dummy parameter to differentiate from the normal constructor)
  24. private GUIElementStyle(bool dummy)
  25. { }
  26. public GUIElementStyle()
  27. {
  28. Internal_CreateInstance(this);
  29. }
  30. public Font font
  31. {
  32. get { Font value; Internal_GetFont(mCachedPtr, out value); return value; }
  33. set { Internal_SetFont(mCachedPtr, value); }
  34. }
  35. public int fontSize
  36. {
  37. get { int value; Internal_GetFontSize(mCachedPtr, out value); return value; }
  38. set { Internal_SetFontSize(mCachedPtr, value); }
  39. }
  40. public TextHorzAlign textHorzAlign
  41. {
  42. get { TextHorzAlign value; Internal_GetTextHorzAlign(mCachedPtr, out value); return value; }
  43. set { Internal_SetTextHorzAlign(mCachedPtr, value); }
  44. }
  45. public TextVertAlign textVertAlign
  46. {
  47. get { TextVertAlign value; Internal_GetTextVertAlign(mCachedPtr, out value); return value; }
  48. set { Internal_SetTextVertAlign(mCachedPtr, value); }
  49. }
  50. public GUIImagePosition imagePosition
  51. {
  52. get { GUIImagePosition value; Internal_GetImagePosition(mCachedPtr, out value); return value; }
  53. set { Internal_SetImagePosition(mCachedPtr, value); }
  54. }
  55. public bool wordWrap
  56. {
  57. get { bool value; Internal_GetWordWrap(mCachedPtr, out value); return value; }
  58. set { Internal_SetWordWrap(mCachedPtr, value); }
  59. }
  60. public GUIElementStateStyle normal
  61. {
  62. get { GUIElementStateStyle value; Internal_GetNormal(mCachedPtr, out value); return value; }
  63. set { Internal_SetNormal(mCachedPtr, value); }
  64. }
  65. public GUIElementStateStyle hover
  66. {
  67. get { GUIElementStateStyle value; Internal_GetHover(mCachedPtr, out value); return value; }
  68. set { Internal_SetHover(mCachedPtr, value); }
  69. }
  70. public GUIElementStateStyle active
  71. {
  72. get { GUIElementStateStyle value; Internal_GetActive(mCachedPtr, out value); return value; }
  73. set { Internal_SetActive(mCachedPtr, value); }
  74. }
  75. public GUIElementStateStyle focused
  76. {
  77. get { GUIElementStateStyle value; Internal_GetFocused(mCachedPtr, out value); return value; }
  78. set { Internal_SetFocused(mCachedPtr, value); }
  79. }
  80. // For controls that can be turned on-off
  81. public GUIElementStateStyle normalOn
  82. {
  83. get { GUIElementStateStyle value; Internal_GetNormalOn(mCachedPtr, out value); return value; }
  84. set { Internal_SetNormalOn(mCachedPtr, value); }
  85. }
  86. public GUIElementStateStyle hoverOn
  87. {
  88. get { GUIElementStateStyle value; Internal_GetHoverOn(mCachedPtr, out value); return value; }
  89. set { Internal_SetHoverOn(mCachedPtr, value); }
  90. }
  91. public GUIElementStateStyle activeOn
  92. {
  93. get { GUIElementStateStyle value; Internal_GetActiveOn(mCachedPtr, out value); return value; }
  94. set { Internal_SetActiveOn(mCachedPtr, value); }
  95. }
  96. public GUIElementStateStyle focusedOn
  97. {
  98. get { GUIElementStateStyle value; Internal_GetFocusedOn(mCachedPtr, out value); return value; }
  99. set { Internal_SetFocusedOn(mCachedPtr, value); }
  100. }
  101. public RectOffset border // Determines how the element is scaled (using the typical Scale9Grid approach)
  102. {
  103. get { RectOffset value; Internal_GetBorder(mCachedPtr, out value); return value; }
  104. set { Internal_SetBorder(mCachedPtr, ref value); }
  105. }
  106. public RectOffset margins // Determines offset from the background graphics to the content. Input uses bounds offset by this value.
  107. {
  108. get { RectOffset value; Internal_GetMargins(mCachedPtr, out value); return value; }
  109. set { Internal_SetMargins(mCachedPtr, ref value); }
  110. }
  111. public RectOffset contentOffset // Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets.
  112. {
  113. get { RectOffset value; Internal_GetContentOffset(mCachedPtr, out value); return value; }
  114. set { Internal_SetContentOffset(mCachedPtr, ref value); }
  115. }
  116. public int width
  117. {
  118. get { int value; Internal_GetWidth(mCachedPtr, out value); return value; }
  119. set { Internal_SetWidth(mCachedPtr, value); }
  120. }
  121. public int height
  122. {
  123. get { int value; Internal_GetHeight(mCachedPtr, out value); return value; }
  124. set { Internal_SetHeight(mCachedPtr, value); }
  125. }
  126. public int minWidth
  127. {
  128. get { int value; Internal_GetMinWidth(mCachedPtr, out value); return value; }
  129. set { Internal_SetMinWidth(mCachedPtr, value); }
  130. }
  131. public int maxWidth
  132. {
  133. get { int value; Internal_GetMaxWidth(mCachedPtr, out value); return value; }
  134. set { Internal_SetMaxWidth(mCachedPtr, value); }
  135. }
  136. public int minHeight
  137. {
  138. get { int value; Internal_GetMinHeight(mCachedPtr, out value); return value; }
  139. set { Internal_SetMinHeight(mCachedPtr, value); }
  140. }
  141. public int maxHeight
  142. {
  143. get { int value; Internal_GetMaxHeight(mCachedPtr, out value); return value; }
  144. set { Internal_SetMaxHeight(mCachedPtr, value); }
  145. }
  146. public bool fixedWidth
  147. {
  148. get { bool value; Internal_GetFixedWidth(mCachedPtr, out value); return value; }
  149. set { Internal_SetFixedWidth(mCachedPtr, value); }
  150. }
  151. public bool fixedHeight
  152. {
  153. get { bool value; Internal_GetFixedHeight(mCachedPtr, out value); return value; }
  154. set { Internal_SetFixedHeight(mCachedPtr, value); }
  155. }
  156. public void AddSubStyle(string guiType, string styleName)
  157. {
  158. if (guiType == null || styleName == null)
  159. return;
  160. Internal_AddSubStyle(mCachedPtr, guiType, styleName);
  161. }
  162. [MethodImpl(MethodImplOptions.InternalCall)]
  163. private static extern void Internal_CreateInstance(GUIElementStyle instance);
  164. [MethodImpl(MethodImplOptions.InternalCall)]
  165. private static extern void Internal_GetFont(IntPtr nativeInstance, out Font value);
  166. [MethodImpl(MethodImplOptions.InternalCall)]
  167. private static extern void Internal_SetFont(IntPtr nativeInstance, Font value);
  168. [MethodImpl(MethodImplOptions.InternalCall)]
  169. private static extern void Internal_GetFontSize(IntPtr nativeInstance, out int value);
  170. [MethodImpl(MethodImplOptions.InternalCall)]
  171. private static extern void Internal_SetFontSize(IntPtr nativeInstance, int value);
  172. [MethodImpl(MethodImplOptions.InternalCall)]
  173. private static extern void Internal_GetTextHorzAlign(IntPtr nativeInstance, out TextHorzAlign value);
  174. [MethodImpl(MethodImplOptions.InternalCall)]
  175. private static extern void Internal_SetTextHorzAlign(IntPtr nativeInstance, TextHorzAlign value);
  176. [MethodImpl(MethodImplOptions.InternalCall)]
  177. private static extern void Internal_GetTextVertAlign(IntPtr nativeInstance, out TextVertAlign value);
  178. [MethodImpl(MethodImplOptions.InternalCall)]
  179. private static extern void Internal_SetTextVertAlign(IntPtr nativeInstance, TextVertAlign value);
  180. [MethodImpl(MethodImplOptions.InternalCall)]
  181. private static extern void Internal_GetImagePosition(IntPtr nativeInstance, out GUIImagePosition value);
  182. [MethodImpl(MethodImplOptions.InternalCall)]
  183. private static extern void Internal_SetImagePosition(IntPtr nativeInstance, GUIImagePosition value);
  184. [MethodImpl(MethodImplOptions.InternalCall)]
  185. private static extern void Internal_GetWordWrap(IntPtr nativeInstance, out bool value);
  186. [MethodImpl(MethodImplOptions.InternalCall)]
  187. private static extern void Internal_SetWordWrap(IntPtr nativeInstance, bool value);
  188. [MethodImpl(MethodImplOptions.InternalCall)]
  189. private static extern void Internal_GetNormal(IntPtr nativeInstance, out GUIElementStateStyle value);
  190. [MethodImpl(MethodImplOptions.InternalCall)]
  191. private static extern void Internal_SetNormal(IntPtr nativeInstance, GUIElementStateStyle value);
  192. [MethodImpl(MethodImplOptions.InternalCall)]
  193. private static extern void Internal_GetHover(IntPtr nativeInstance, out GUIElementStateStyle value);
  194. [MethodImpl(MethodImplOptions.InternalCall)]
  195. private static extern void Internal_SetHover(IntPtr nativeInstance, GUIElementStateStyle value);
  196. [MethodImpl(MethodImplOptions.InternalCall)]
  197. private static extern void Internal_GetActive(IntPtr nativeInstance, out GUIElementStateStyle value);
  198. [MethodImpl(MethodImplOptions.InternalCall)]
  199. private static extern void Internal_SetActive(IntPtr nativeInstance, GUIElementStateStyle value);
  200. [MethodImpl(MethodImplOptions.InternalCall)]
  201. private static extern void Internal_GetFocused(IntPtr nativeInstance, out GUIElementStateStyle value);
  202. [MethodImpl(MethodImplOptions.InternalCall)]
  203. private static extern void Internal_SetFocused(IntPtr nativeInstance, GUIElementStateStyle value);
  204. [MethodImpl(MethodImplOptions.InternalCall)]
  205. private static extern void Internal_GetNormalOn(IntPtr nativeInstance, out GUIElementStateStyle value);
  206. [MethodImpl(MethodImplOptions.InternalCall)]
  207. private static extern void Internal_SetNormalOn(IntPtr nativeInstance, GUIElementStateStyle value);
  208. [MethodImpl(MethodImplOptions.InternalCall)]
  209. private static extern void Internal_GetHoverOn(IntPtr nativeInstance, out GUIElementStateStyle value);
  210. [MethodImpl(MethodImplOptions.InternalCall)]
  211. private static extern void Internal_SetHoverOn(IntPtr nativeInstance, GUIElementStateStyle value);
  212. [MethodImpl(MethodImplOptions.InternalCall)]
  213. private static extern void Internal_GetActiveOn(IntPtr nativeInstance, out GUIElementStateStyle value);
  214. [MethodImpl(MethodImplOptions.InternalCall)]
  215. private static extern void Internal_SetActiveOn(IntPtr nativeInstance, GUIElementStateStyle value);
  216. [MethodImpl(MethodImplOptions.InternalCall)]
  217. private static extern void Internal_GetFocusedOn(IntPtr nativeInstance, out GUIElementStateStyle value);
  218. [MethodImpl(MethodImplOptions.InternalCall)]
  219. private static extern void Internal_SetFocusedOn(IntPtr nativeInstance, GUIElementStateStyle value);
  220. [MethodImpl(MethodImplOptions.InternalCall)]
  221. private static extern void Internal_GetBorder(IntPtr nativeInstance, out RectOffset value);
  222. [MethodImpl(MethodImplOptions.InternalCall)]
  223. private static extern void Internal_SetBorder(IntPtr nativeInstance, ref RectOffset value);
  224. [MethodImpl(MethodImplOptions.InternalCall)]
  225. private static extern void Internal_GetMargins(IntPtr nativeInstance, out RectOffset value);
  226. [MethodImpl(MethodImplOptions.InternalCall)]
  227. private static extern void Internal_SetMargins(IntPtr nativeInstance, ref RectOffset value);
  228. [MethodImpl(MethodImplOptions.InternalCall)]
  229. private static extern void Internal_GetContentOffset(IntPtr nativeInstance, out RectOffset value);
  230. [MethodImpl(MethodImplOptions.InternalCall)]
  231. private static extern void Internal_SetContentOffset(IntPtr nativeInstance, ref RectOffset value);
  232. [MethodImpl(MethodImplOptions.InternalCall)]
  233. private static extern void Internal_GetWidth(IntPtr nativeInstance, out int value);
  234. [MethodImpl(MethodImplOptions.InternalCall)]
  235. private static extern void Internal_SetWidth(IntPtr nativeInstance, int value);
  236. [MethodImpl(MethodImplOptions.InternalCall)]
  237. private static extern void Internal_GetHeight(IntPtr nativeInstance, out int value);
  238. [MethodImpl(MethodImplOptions.InternalCall)]
  239. private static extern void Internal_SetHeight(IntPtr nativeInstance, int value);
  240. [MethodImpl(MethodImplOptions.InternalCall)]
  241. private static extern void Internal_GetMinWidth(IntPtr nativeInstance, out int value);
  242. [MethodImpl(MethodImplOptions.InternalCall)]
  243. private static extern void Internal_SetMinWidth(IntPtr nativeInstance, int value);
  244. [MethodImpl(MethodImplOptions.InternalCall)]
  245. private static extern void Internal_GetMaxWidth(IntPtr nativeInstance, out int value);
  246. [MethodImpl(MethodImplOptions.InternalCall)]
  247. private static extern void Internal_SetMaxWidth(IntPtr nativeInstance, int value);
  248. [MethodImpl(MethodImplOptions.InternalCall)]
  249. private static extern void Internal_GetMinHeight(IntPtr nativeInstance, out int value);
  250. [MethodImpl(MethodImplOptions.InternalCall)]
  251. private static extern void Internal_SetMinHeight(IntPtr nativeInstance, int value);
  252. [MethodImpl(MethodImplOptions.InternalCall)]
  253. private static extern void Internal_GetMaxHeight(IntPtr nativeInstance, out int value);
  254. [MethodImpl(MethodImplOptions.InternalCall)]
  255. private static extern void Internal_SetMaxHeight(IntPtr nativeInstance, int value);
  256. [MethodImpl(MethodImplOptions.InternalCall)]
  257. private static extern void Internal_GetFixedWidth(IntPtr nativeInstance, out bool value);
  258. [MethodImpl(MethodImplOptions.InternalCall)]
  259. private static extern void Internal_SetFixedWidth(IntPtr nativeInstance, bool value);
  260. [MethodImpl(MethodImplOptions.InternalCall)]
  261. private static extern void Internal_GetFixedHeight(IntPtr nativeInstance, out bool value);
  262. [MethodImpl(MethodImplOptions.InternalCall)]
  263. private static extern void Internal_SetFixedHeight(IntPtr nativeInstance, bool value);
  264. [MethodImpl(MethodImplOptions.InternalCall)]
  265. private static extern void Internal_AddSubStyle(IntPtr nativeInstance, string guiType, string styleName);
  266. }
  267. }