SizeRequest.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #region MIT License
  2. /*Copyright (c) 2012 Robert Rouhani <robert.rouhani@gmail.com>
  3. SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
  4. Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. this software and associated documentation files (the "Software"), to deal in
  6. the Software without restriction, including without limitation the rights to
  7. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  8. of the Software, and to permit persons to whom the Software is furnished to do
  9. so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.*/
  19. #endregion
  20. using System;
  21. using System.Runtime.InteropServices;
  22. namespace SharpFont
  23. {
  24. /// <summary>
  25. /// A structure used to model a size request.
  26. /// </summary>
  27. /// <remarks>
  28. /// If <see cref="Width"/> is zero, then the horizontal scaling value is set equal to the vertical scaling value,
  29. /// and vice versa.
  30. /// </remarks>
  31. [StructLayout(LayoutKind.Sequential)]
  32. public sealed class SizeRequest
  33. {
  34. //HACK still need a rec for this.
  35. #region Fields
  36. private IntPtr reference;
  37. #endregion
  38. #region Constructors
  39. internal SizeRequest(IntPtr reference)
  40. {
  41. Reference = reference;
  42. }
  43. #endregion
  44. #region Properties
  45. /// <summary>
  46. /// See <see cref="SizeRequestType"/>.
  47. /// </summary>
  48. public SizeRequestType RequestType
  49. {
  50. get
  51. {
  52. return (SizeRequestType)Marshal.ReadInt32(reference, 0);
  53. }
  54. }
  55. /// <summary>
  56. /// Gets the desired width.
  57. /// </summary>
  58. public int Width
  59. {
  60. get
  61. {
  62. return Marshal.ReadInt32(reference, 4);
  63. }
  64. }
  65. /// <summary>
  66. /// Gets the desired height.
  67. /// </summary>
  68. public int Height
  69. {
  70. get
  71. {
  72. return Marshal.ReadInt32(reference, 8);
  73. }
  74. }
  75. /// <summary>
  76. /// Gets the horizontal resolution. If set to zero, <see cref="Width"/> is treated as a 26.6 fractional pixel
  77. /// value.
  78. /// </summary>
  79. [CLSCompliant(false)]
  80. public uint HorizontalResolution
  81. {
  82. get
  83. {
  84. return (uint)Marshal.ReadInt32(reference, 12);
  85. }
  86. }
  87. /// <summary>
  88. /// Gets the horizontal resolution. If set to zero, <see cref="Height"/> is treated as a 26.6 fractional pixel
  89. /// value.
  90. /// </summary>
  91. [CLSCompliant(false)]
  92. public uint VerticalResolution
  93. {
  94. get
  95. {
  96. return (uint)Marshal.ReadInt32(reference, 16);
  97. }
  98. }
  99. internal IntPtr Reference
  100. {
  101. get
  102. {
  103. return reference;
  104. }
  105. set
  106. {
  107. reference = value;
  108. }
  109. }
  110. #endregion
  111. }
  112. }