iup_gauge.e 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. class IUP_GAUGE
  2. -- Creates a Gauge control. Shows a percent value that can be updated to
  3. -- simulate a progression. It inherits from IUP_CANVAS.
  4. --
  5. -- Callbacks:
  6. --
  7. -- MAP_CB, UNMAP_CB, DESTROY_CB: common callbacks are supported.
  8. --
  9. -- Notes:
  10. --
  11. -- To replace a IUP_PROGRESS_BAR by a IUP_GAUGE you should set
  12. -- set_raster_size=200x30 and set_show_text=False.
  13. inherit
  14. IUP_CANVAS
  15. redefine
  16. set_size
  17. end
  18. IUP_WIDGET_FGCOLOR
  19. redefine
  20. set_rgb_foreground_color
  21. end
  22. IUP_WIDGET_FLAT
  23. IUP_WIDGET_PADDING
  24. create {ANY}
  25. gauge
  26. feature {ANY}
  27. gauge
  28. local
  29. a_gauge: POINTER
  30. do
  31. a_gauge := int_gauge
  32. set_widget(a_gauge)
  33. end
  34. -- Attributes
  35. set_rgb_back_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  36. -- (non inheritable): color of the background inside the
  37. -- borders. Predefined to "220 220 220.
  38. do
  39. iup_open.set_attribute(Current, "BACKCOLOR", rgb_to_string(red, green, blue))
  40. end
  41. reset_back_color
  42. -- Use the parent's background color.
  43. do
  44. iup_open.reset_attribute(Current, "BACKCOLOR")
  45. end
  46. set_dashed (state: BOOLEAN)
  47. -- Changes the style of the gauge for a dashed pattern. Default=False.
  48. do
  49. iup_open.set_attribute(Current, "DASHED", boolean_to_yesno(state))
  50. end
  51. set_rgb_foreground_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  52. -- Controls the gauge and text color. The default is "64 96 192".
  53. do
  54. Precursor (red, green, blue)
  55. end
  56. set_max (value: REAL)
  57. -- (non inheritable): Contains the maximum value. Default is "1".
  58. do
  59. iup_open.set_attribute(Current, "MAX", value.out)
  60. end
  61. set_min (value: REAL)
  62. -- (non inheritable): Contains the minimum value. Default is "0".
  63. do
  64. iup_open.set_attribute(Current, "MIN", value.out)
  65. end
  66. set_horizontal_orientation
  67. -- (creation only): Horizontal goes from left to right. Width and height
  68. -- are swapped when orientation is set. This is the default value.
  69. do
  70. iup_open.set_attribute(Current, "ORIENTATION", "HORIZONTAL")
  71. end
  72. set_vertical_orientation
  73. -- (creation only): Vertical from bottom to top. Width and height are
  74. -- swapped when orientation is set.
  75. do
  76. iup_open.set_attribute(Current, "ORIENTATION", "VERTICAL")
  77. end
  78. set_show_text (state: BOOLEAN)
  79. -- Indicates if the text inside the Gauge is to be shown or not. If the
  80. -- gauge is dashed the text is never shown. Default: "True".
  81. do
  82. iup_open.set_attribute(Current, "SHOWTEXT", boolean_to_yesno(state))
  83. end
  84. set_size (width: INTEGER; height: INTEGER)
  85. -- (non inheritable): The initial size is "120x14".
  86. do
  87. Precursor (width, height)
  88. end
  89. set_automatic_layout
  90. -- Set to allow the automatic layout use smaller values.
  91. do
  92. iup_open.set_attribute_null(Current, "SIZE")
  93. end
  94. set_text (value: STRING)
  95. -- (non inheritable): Contains a text to be shown inside the Gauge when
  96. -- set_show_text=True.
  97. do
  98. iup_open.set_attribute(Current, "TEXT", value)
  99. end
  100. set_use_percent
  101. -- The percentage calculated from VALUE will be used. If the gauge is
  102. -- dashed the text is never shown.
  103. do
  104. iup_open.set_attribute_null(Current, "TEXT")
  105. end
  106. set_value (value: REAL)
  107. -- (non inheritable): Contains a number between "MIN" and "MAX",
  108. -- controlling the current position.
  109. do
  110. iup_open.set_attribute(Current, "VALUE", value.out)
  111. end
  112. feature {NONE}
  113. -- Internals
  114. int_gauge: POINTER
  115. external
  116. "C inline use %"eiffel-iup.h%""
  117. alias
  118. "return IupGauge ();"
  119. end
  120. end -- class IUP_GAUGE
  121. -- The MIT License (MIT)
  122. -- Copyright (c) 2019, 2020 by German A. Arias
  123. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  124. -- of this software and associated documentation files (the "Software"), to deal
  125. -- in the Software without restriction, including without limitation the rights
  126. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  127. -- copies of the Software, and to permit persons to whom the Software is
  128. -- furnished to do so, subject to the following conditions:
  129. --
  130. -- The above copyright notice and this permission notice shall be included in
  131. -- all copies or substantial portions of the Software.
  132. --
  133. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  134. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  135. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  136. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  137. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  138. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  139. -- SOFTWARE.