iup_gauge.e 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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_dashed (state: BOOLEAN)
  36. -- Changes the style of the gauge for a dashed pattern. Default=False.
  37. do
  38. iup_open.set_attribute(Current, "DASHED", boolean_to_yesno(state))
  39. end
  40. set_rgb_foreground_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  41. -- Controls the gauge and text color. The default is "64 96 192".
  42. do
  43. Precursor (red, green, blue)
  44. end
  45. set_max (value: REAL)
  46. -- (non inheritable): Contains the maximum value. Default is "1".
  47. do
  48. iup_open.set_attribute(Current, "MAX", value.to_string)
  49. end
  50. set_min (value: REAL)
  51. -- (non inheritable): Contains the minimum value. Default is "0".
  52. do
  53. iup_open.set_attribute(Current, "MIN", value.to_string)
  54. end
  55. set_horizontal_orientation
  56. -- (creation only): Horizontal goes from left to right. Width and height
  57. -- are swapped when orientation is set. This is the default value.
  58. do
  59. iup_open.set_attribute(Current, "ORIENTATION", "HORIZONTAL")
  60. end
  61. set_vertical_orientation
  62. -- (creation only): Vertical from bottom to top. Width and height are
  63. -- swapped when orientation is set.
  64. do
  65. iup_open.set_attribute(Current, "ORIENTATION", "VERTICAL")
  66. end
  67. set_show_text (state: BOOLEAN)
  68. -- Indicates if the text inside the Gauge is to be shown or not. If the
  69. -- gauge is dashed the text is never shown. Default: "True".
  70. do
  71. iup_open.set_attribute(Current, "SHOWTEXT", boolean_to_yesno(state))
  72. end
  73. set_size (width: INTEGER; height: INTEGER)
  74. -- (non inheritable): The initial size is "120x14".
  75. do
  76. Precursor (width, height)
  77. end
  78. set_automatic_layout
  79. -- Set to allow the automatic layout use smaller values.
  80. do
  81. iup_open.set_attribute_null(Current, "SIZE")
  82. end
  83. set_text (value: STRING)
  84. -- (non inheritable): Contains a text to be shown inside the Gauge when
  85. -- set_show_text=True.
  86. do
  87. iup_open.set_attribute(Current, "TEXT", value)
  88. end
  89. set_use_percent
  90. -- The percentage calculated from VALUE will be used. If the gauge is
  91. -- dashed the text is never shown.
  92. do
  93. iup_open.set_attribute_null(Current, "TEXT")
  94. end
  95. set_value (value: REAL)
  96. -- (non inheritable): Contains a number between "MIN" and "MAX",
  97. -- controlling the current position.
  98. do
  99. iup_open.set_attribute(Current, "VALUE", value.to_string)
  100. end
  101. feature {}
  102. -- Internals
  103. int_gauge: POINTER
  104. external "plug_in"
  105. alias "{
  106. location: "${sys}/plugins"
  107. module_name: "iup"
  108. feature_name: "IupGauge()"
  109. }"
  110. end
  111. end -- class IUP_GAUGE
  112. -- The MIT License (MIT)
  113. -- Copyright (c) 2019 by German A. Arias
  114. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  115. -- of this software and associated documentation files (the "Software"), to deal
  116. -- in the Software without restriction, including without limitation the rights
  117. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  118. -- copies of the Software, and to permit persons to whom the Software is
  119. -- furnished to do so, subject to the following conditions:
  120. --
  121. -- The above copyright notice and this permission notice shall be included in
  122. -- all copies or substantial portions of the Software.
  123. --
  124. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  125. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  126. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  127. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  128. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  129. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  130. -- SOFTWARE.