iup_widget_flat_scroll_box.e 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. deferred class IUP_WIDGET_FLAT_SCROLL_BOX
  2. -- Complementary attributes when a flat scrollbar is used (a drawn scrollbar).
  3. --
  4. -- Used in IUP_FLAT_SCROLL_BOX, and in IUP_MATRIX when FLATSCROLLBAR is defined.
  5. inherit
  6. IUP_WIDGET_INTERNALS
  7. feature {ANY}
  8. set_flat_scroll_bar (style: STRING)
  9. require
  10. is_valid_style(style)
  11. do
  12. iup_open.set_attribute(Current, "FLATSCROLLBAR", style)
  13. end
  14. -- Attributes
  15. set_rgb_back_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  16. -- (non inheritable): color used as background for the scrollbar. By
  17. -- default it will inherit from BGCOLOR.
  18. do
  19. iup_open.set_attribute(Current, "SB_BACKCOLOR", rgb_to_string(red, green, blue))
  20. end
  21. get_rgb_back_color: TUPLE[INTEGER, INTEGER, INTEGER]
  22. do
  23. Result := iup_open.get_rgb(Current, "SB_BACKCOLOR")
  24. end
  25. reset_back_color
  26. -- Reset the back color to the default value.
  27. do
  28. iup_open.reset_attribute(Current, "SB_BACKCOLOR")
  29. end
  30. set_rgb_fore_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  31. -- (non inheritable): handler and arrow color. Default: "220 220 220".
  32. -- Used instead of FGCOLOR to avoid inheritance problems.
  33. do
  34. iup_open.set_attribute(Current, "SB_FORECOLOR", rgb_to_string(red, green, blue))
  35. end
  36. get_rgb_fore_color: TUPLE[INTEGER, INTEGER, INTEGER]
  37. do
  38. Result := iup_open.get_rgb(Current, "SB_FORECOLOR")
  39. end
  40. reset_fore_color
  41. -- Reset the fore color to the default value.
  42. do
  43. iup_open.reset_attribute(Current, "SB_FORECOLOR")
  44. end
  45. set_rgb_high_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  46. -- (non inheritable): handler and arrow color when highlight.
  47. -- Default: "132 132 132".
  48. do
  49. iup_open.set_attribute(Current, "SB_HIGHCOLOR", rgb_to_string(red, green, blue))
  50. end
  51. get_rgb_high_color: TUPLE[INTEGER, INTEGER, INTEGER]
  52. do
  53. Result := iup_open.get_rgb(Current, "SB_HIGHCOLOR")
  54. end
  55. reset_high_color
  56. -- Reset the high color to the default value.
  57. do
  58. iup_open.reset_attribute(Current, "SB_HIGHCOLOR")
  59. end
  60. set_rgb_press_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  61. -- (non inheritable): handler and arrow color when pressed.
  62. -- Default: "96 96 96".
  63. do
  64. iup_open.set_attribute(Current, "SB_PRESSCOLOR", rgb_to_string(red, green, blue))
  65. end
  66. get_rgb_press_color: TUPLE[INTEGER, INTEGER, INTEGER]
  67. do
  68. Result := iup_open.get_rgb(Current, "SB_PRESSCOLOR")
  69. end
  70. reset_press_color
  71. -- Reset the press color to the default value.
  72. do
  73. iup_open.reset_attribute(Current, "SB_PRESSCOLOR")
  74. end
  75. set_scroll_bar_size (size: INTEGER)
  76. -- (non inheritable): The width of the vertical scrollbar or the height
  77. -- of the horizontal scrollbar. Default: 15.
  78. do
  79. iup_open.set_attribute(Current, "SCROLLBARSIZE", size.out)
  80. end
  81. get_scroll_bar_size: INTEGER
  82. local
  83. str: STRING
  84. do
  85. str := iup_open.get_attribute(Current, "SCROLLBARSIZE")
  86. Result := str.to_integer
  87. end
  88. set_show_arrows (state: BOOLEAN)
  89. -- (non inheritable): Allow to show or hide the arrows. Default: "True".
  90. do
  91. iup_open.set_attribute(Current, "SHOWARROWS", boolean_to_yesno(state))
  92. end
  93. get_show_arrows: BOOLEAN
  94. local
  95. str: STRING
  96. do
  97. str := iup_open.get_attribute(Current, "SHOWARROWS")
  98. Result := yesno_to_boolean(str)
  99. end
  100. set_show_floating (state: BOOLEAN)
  101. -- (non inheritable): the scrollbar is shown only when used, over the
  102. -- space it occupied. Move the mouse over the scrollbar area to show the
  103. -- scrollbars. They are automatically hidden after not being used by the
  104. -- time defined in FLOATINGDELAY. Default: "False".
  105. do
  106. iup_open.set_attribute(Current, "SHOWFLOATING", boolean_to_yesno(state))
  107. end
  108. get_show_floating: BOOLEAN
  109. local
  110. str: STRING
  111. do
  112. str := iup_open.get_attribute(Current, "SHOWFLOATING")
  113. Result := yesno_to_boolean(str)
  114. end
  115. set_show_transparent (state: BOOLEAN)
  116. -- (non inheritable): This makes the flat scrollbar semi transparent and
  117. -- only interactive trough its handler. It implies in
  118. -- set_show_arrows=False and set_show_floating=True.
  119. do
  120. iup_open.set_attribute(Current, "SHOWTRANSPARENT", boolean_to_yesno(state))
  121. end
  122. set_floating_delay (delay: INTEGER)
  123. -- (non inheritable): time to hide the scrollbar when SHOWFLOATING=Yes in
  124. -- milliseconds. Default: 2000.
  125. do
  126. iup_open.set_attribute(Current, "FLOATINGDELAY", delay.out)
  127. end
  128. get_floating_delay: INTEGER
  129. local
  130. str: STRING
  131. do
  132. str := iup_open.get_attribute(Current, "FLOATINGDELAY")
  133. Result := str.to_integer
  134. end
  135. set_arrow_images (state: BOOLEAN)
  136. -- (non inheritable): replace the drawn arrows by the following images.
  137. -- Default: "False".
  138. do
  139. iup_open.set_attribute(Current, "ARROWIMAGES", boolean_to_yesno(state))
  140. end
  141. get_arrow_images: BOOLEAN
  142. local
  143. str: STRING
  144. do
  145. str := iup_open.get_attribute(Current, "ARROWIMAGES")
  146. Result := yesno_to_boolean(str)
  147. end
  148. set_image_left (name: STRING)
  149. -- Arrow image name (the attribute is relative to where the arrow is
  150. -- pointing). Use set_widget_name to associate an image to a name.
  151. -- See also IUP_IMAGE. IMPORTANT = all images must be square with side
  152. -- equals to SCROLLBARSIZE.
  153. do
  154. iup_open.set_attribute(Current, "SB_IMAGELEFT", name)
  155. end
  156. get_image_left: STRING
  157. do
  158. Result := iup_open.get_attribute(Current, "SB_IMAGELEFT")
  159. end
  160. set_image_right (name: STRING)
  161. -- Arrow image name (the attribute is relative to where the arrow is
  162. -- pointing). Use set_widget_name to associate an image to a name.
  163. -- See also IUP_IMAGE. IMPORTANT = all images must be square with side
  164. -- equals to SCROLLBARSIZE.
  165. do
  166. iup_open.set_attribute(Current, "SB_IMAGERIGHT", name)
  167. end
  168. get_image_right: STRING
  169. do
  170. Result := iup_open.get_attribute(Current, "SB_IMAGERIGHT")
  171. end
  172. set_image_top (name: STRING)
  173. -- Arrow image name (the attribute is relative to where the arrow is
  174. -- pointing). Use set_widget_name to associate an image to a name.
  175. -- See also IUP_IMAGE. IMPORTANT = all images must be square with side
  176. -- equals to SCROLLBARSIZE.
  177. do
  178. iup_open.set_attribute(Current, "SB_IMAGETOP", name)
  179. end
  180. get_image_top: STRING
  181. do
  182. Result := iup_open.get_attribute(Current, "SB_IMAGETOP")
  183. end
  184. set_image_bottom (name: STRING)
  185. -- Arrow image name (the attribute is relative to where the arrow is
  186. -- pointing). Use set_widget_name to associate an image to a name.
  187. -- See also IUP_IMAGE. IMPORTANT = all images must be square with side
  188. -- equals to SCROLLBARSIZE.
  189. do
  190. iup_open.set_attribute(Current, "SB_IMAGEBOTTOM", name)
  191. end
  192. get_image_bottom: STRING
  193. do
  194. Result := iup_open.get_attribute(Current, "SB_IMAGEBOTTOM")
  195. end
  196. set_image_left_highlight (name: STRING)
  197. -- (non inheritable): Arrow image name of the element in highlight state.
  198. -- If it is not defined then the IMAGELEFT is used.
  199. do
  200. iup_open.set_attribute(Current, "SB_IMAGELEFTHIGHLIGHT", name)
  201. end
  202. get_image_left_highlight: STRING
  203. do
  204. Result := iup_open.get_attribute(Current, "SB_IMAGELEFTHIGHLIGHT")
  205. end
  206. set_image_right_highlight (name: STRING)
  207. -- (non inheritable): Arrow image name of the element in highlight state.
  208. -- If it is not defined then the IMAGERIGHT is used.
  209. do
  210. iup_open.set_attribute(Current, "SB_IMAGERIGHTHIGHLIGHT", name)
  211. end
  212. get_image_right_highlight: STRING
  213. do
  214. Result := iup_open.get_attribute(Current, "SB_IMAGERIGHTHIGHLIGHT")
  215. end
  216. set_image_top_highlight (name: STRING)
  217. -- (non inheritable): Arrow image name of the element in highlight state.
  218. -- If it is not defined then the IMAGETOP is used.
  219. do
  220. iup_open.set_attribute(Current, "SB_IMAGETOPHIGHLIGHT", name)
  221. end
  222. get_image_top_highlight: STRING
  223. do
  224. Result := iup_open.get_attribute(Current, "SB_IMAGETOPHIGHLIGHT")
  225. end
  226. set_image_bottom_highlight (name: STRING)
  227. -- (non inheritable): Arrow image name of the element in highlight state.
  228. -- If it is not defined then the IMAGEBOTTOM is used.
  229. do
  230. iup_open.set_attribute(Current, "SB_IMAGEBOTTOMHIGHLIGHT", name)
  231. end
  232. get_image_bottom_highlight: STRING
  233. do
  234. Result := iup_open.get_attribute(Current, "SB_IMAGEBOTTOMHIGHLIGHT")
  235. end
  236. set_image_left_inactive (name: STRING)
  237. -- (non inheritable): Arrow image name of the element when inactive. If
  238. -- it is not defined then the IMAGELEFT is used and its colors will be
  239. -- replaced by a modified version creating the disabled effect.
  240. do
  241. iup_open.set_attribute(Current, "SB_IMAGELEFTINACTIVE", name)
  242. end
  243. get_image_left_inactive: STRING
  244. do
  245. Result := iup_open.get_attribute(Current, "SB_IMAGELEFTINACTIVE")
  246. end
  247. set_image_right_inactive (name: STRING)
  248. -- (non inheritable): Arrow image name of the element when inactive. If
  249. -- it is not defined then the IMAGERIGHT is used and its colors will be
  250. -- replaced by a modified version creating the disabled effect.
  251. do
  252. iup_open.set_attribute(Current, "SB_IMAGERIGHTINACTIVE", name)
  253. end
  254. get_image_right_inactive: STRING
  255. do
  256. Result := iup_open.get_attribute(Current, "SB_IMAGERIGHTINACTIVE")
  257. end
  258. set_image_top_inactive (name: STRING)
  259. -- (non inheritable): Arrow image name of the element when inactive. If
  260. -- it is not defined then the IMAGETOP is used and its colors will be
  261. -- replaced by a modified version creating the disabled effect.
  262. do
  263. iup_open.set_attribute(Current, "SB_IMAGETOPINACTIVE", name)
  264. end
  265. get_image_top_inactive: STRING
  266. do
  267. Result := iup_open.get_attribute(Current, "SB_IMAGETOPINACTIVE")
  268. end
  269. set_image_bottom_inactive (name: STRING)
  270. -- (non inheritable): Arrow image name of the element when inactive. If
  271. -- it is not defined then the IMAGEBOTTOM is used and its colors will be
  272. -- replaced by a modified version creating the disabled effect.
  273. do
  274. iup_open.set_attribute(Current, "SB_IMAGEBOTTOMINACTIVE", name)
  275. end
  276. get_image_bottom_inactive: STRING
  277. do
  278. Result := iup_open.get_attribute(Current, "SB_IMAGEBOTTOMINACTIVE")
  279. end
  280. set_image_left_press (name: STRING)
  281. -- (non inheritable): Arrow image name of the element in pressed state.
  282. -- If it is not defined then the IMAGELEFT is used.
  283. do
  284. iup_open.set_attribute(Current, "SB_IMAGELEFTPRESS", name)
  285. end
  286. get_image_left_press: STRING
  287. do
  288. Result := iup_open.get_attribute(Current, "SB_IMAGELEFTPRESS")
  289. end
  290. set_image_right_press (name: STRING)
  291. -- (non inheritable): Arrow image name of the element in pressed state.
  292. -- If it is not defined then the IMAGERIGHT is used.
  293. do
  294. iup_open.set_attribute(Current, "SB_IMAGERIGHTPRESS", name)
  295. end
  296. get_image_right_press: STRING
  297. do
  298. Result := iup_open.get_attribute(Current, "SB_IMAGERIGHTPRESS")
  299. end
  300. set_image_top_press (name: STRING)
  301. -- (non inheritable): Arrow image name of the element in pressed state.
  302. -- If it is not defined then the IMAGETOP is used.
  303. do
  304. iup_open.set_attribute(Current, "SB_IMAGETOPPRESS", name)
  305. end
  306. get_image_top_press: STRING
  307. do
  308. Result := iup_open.get_attribute(Current, "SB_IMAGETOPPRESS")
  309. end
  310. set_image_bottom_press (name: STRING)
  311. -- (non inheritable): Arrow image name of the element in pressed state.
  312. -- If it is not defined then the IMAGEBOTTOM is used.
  313. do
  314. iup_open.set_attribute(Current, "SB_IMAGEBOTTOMPRESS", name)
  315. end
  316. get_image_bottom_press: STRING
  317. do
  318. Result := iup_open.get_attribute(Current, "SB_IMAGEBOTTOMPRESS")
  319. end
  320. -- Validations
  321. is_valid_style (value: STRING): BOOLEAN
  322. do
  323. if value.is_equal("YES") or
  324. value.is_equal("VERTICAL") or
  325. value.is_equal("HORIZONTAL") then
  326. Result := True
  327. else
  328. Result := False
  329. end
  330. end
  331. end
  332. -- The MIT License (MIT)
  333. -- Copyright (c) 2017, 2019 by German A. Arias
  334. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  335. -- of this software and associated documentation files (the "Software"), to deal
  336. -- in the Software without restriction, including without limitation the rights
  337. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  338. -- copies of the Software, and to permit persons to whom the Software is
  339. -- furnished to do so, subject to the following conditions:
  340. --
  341. -- The above copyright notice and this permission notice shall be included in
  342. -- all copies or substantial portions of the Software.
  343. --
  344. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  345. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  346. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  347. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  348. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  349. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  350. -- SOFTWARE.