iup_widget_flat_scroll_box.e 12 KB

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