iup_spin_box.e 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. class IUP_SPIN_BOX
  2. -- An horizontal container that already contains a IUP_SPIN.
  3. inherit
  4. IUP_CONTAINER
  5. redefine
  6. execute_spin
  7. end
  8. IUP_WIDGET_CHILD
  9. IUP_WIDGET_NAME
  10. create {ANY}
  11. spin_box
  12. feature {ANY}
  13. spin_box_empty
  14. -- A new empty spin box.
  15. local
  16. a_spin_box, p: POINTER
  17. do
  18. a_spin_box := int_spin_box(p)
  19. set_widget(a_spin_box)
  20. end
  21. spin_box(child: IUP_WIDGET)
  22. -- A new spin box with the given child.
  23. local
  24. a_spin_box: POINTER
  25. do
  26. a_spin_box := int_spin_box(child.widget)
  27. set_widget(a_spin_box)
  28. end
  29. -- Callback
  30. set_cb_spin (act: FUNCTION[TUPLE[IUP_SPIN_BOX, INTEGER], STRING])
  31. -- Called each time the user clicks in the buttons. It will increment 1
  32. -- and decrement -1 by default. Holding the Shift key will set a factor
  33. -- of 2, holding Ctrl a factor of 10, and both a factor of 100.
  34. local
  35. operation: INTEGER
  36. do
  37. cb_spin := act
  38. if cb_spin /= Void then
  39. operation := 1
  40. else
  41. operation := 0
  42. end
  43. iup_open.set_callback (Current, "SPIN_CB", "NONEEDED", operation)
  44. end
  45. feature {IUP}
  46. execute_spin (inc: INTEGER): STRING
  47. do
  48. Result := cb_spin.item([Current, inc])
  49. end
  50. feature {}
  51. -- For callback
  52. cb_spin: FUNCTION[TUPLE[IUP_SPIN_BOX, INTEGER], STRING]
  53. -- Internal
  54. int_spin_box (wgt: POINTER): POINTER
  55. external "plug_in"
  56. alias "{
  57. location: "${sys}/plugins"
  58. module_name: "iup"
  59. feature_name: "IupSpinbox"
  60. }"
  61. end
  62. end
  63. -- The MIT License (MIT)
  64. -- Copyright (c) 2016 by German A. Arias
  65. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  66. -- of this software and associated documentation files (the "Software"), to deal
  67. -- in the Software without restriction, including without limitation the rights
  68. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  69. -- copies of the Software, and to permit persons to whom the Software is
  70. -- furnished to do so, subject to the following conditions:
  71. --
  72. -- The above copyright notice and this permission notice shall be included in
  73. -- all copies or substantial portions of the Software.
  74. --
  75. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  76. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  77. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  78. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  79. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  80. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  81. -- SOFTWARE.