iup_background_box.e 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. class IUP_BACKGROUND_BOX
  2. -- Creates a simple native container with no decorations. Useful for
  3. -- controlling children visibility for IUP_ZBOX or IUP_EXPANDER.
  4. -- The box can be created with no elements and be dynamic filled using
  5. -- "append" or "insert".
  6. inherit
  7. IUP_CANVAS
  8. redefine
  9. set_border,
  10. set_can_focus
  11. end
  12. IUP_WIDGET_CLIENTSIZE
  13. IUP_WIDGET_CLIENTOFFSET
  14. IUP_WIDGET_DECORATION
  15. IUP_WIDGET_BGCOLOR
  16. IUP_WIDGET_BACK_IMAGE_0
  17. create {ANY}
  18. background_box_empty,
  19. background_box
  20. feature {ANY}
  21. background_box_empty
  22. local
  23. a_background_box, p: POINTER
  24. do
  25. a_background_box := int_background_box (p)
  26. set_widget(a_background_box)
  27. end
  28. background_box (child: IUP_WIDGET)
  29. local
  30. a_background_box: POINTER
  31. do
  32. a_background_box := int_background_box (child.widget)
  33. set_widget(a_background_box)
  34. end
  35. -- Commands to handle attributes
  36. set_border (state: BOOLEAN)
  37. -- (creation only): the default value is "False".
  38. do
  39. Precursor(state)
  40. end
  41. has_border: BOOLEAN
  42. -- Return if the element has border.
  43. local
  44. str: STRING
  45. do
  46. str := iup_open.get_attribute(Current, "BORDER")
  47. Result := yesno_to_boolean(str)
  48. end
  49. set_canvas_box (state: BOOLEAN)
  50. -- (non inheritable): enable the behavior of a canvas box instead of a
  51. -- regular container. Default: "False".
  52. do
  53. iup_open.set_attribute(Current, "CANVASBOX", boolean_to_yesno(state))
  54. end
  55. set_child_offset (dx, dy: INTEGER)
  56. -- Allow to specify a position offset for the child. Available for native
  57. -- containers only. It will not affect the natural size, and allows to
  58. -- position controls outside the client area. Format "dxxdy", where dx
  59. -- and dy are integer values corresponding to the horizontal and vertical
  60. -- offsets, respectively, in pixels. Default: 0x0.
  61. require
  62. non_negative: dx >= 0
  63. dy >= 0
  64. local
  65. size: STRING
  66. do
  67. size := dx.out
  68. size.append_string("x")
  69. size.append_string(dy.out)
  70. iup_open.set_attribute(Current, "CHILDOFFSET", size)
  71. end
  72. get_child_offset: TUPLE[INTEGER, INTEGER]
  73. -- The child offset.
  74. local
  75. offset: STRING
  76. do
  77. offset := iup_open.get_attribute(Current, "CHILDOFFSET")
  78. Result := components_of_size(offset)
  79. end
  80. set_can_focus (state: BOOLEAN)
  81. -- Default: False.
  82. do
  83. Precursor (state)
  84. end
  85. feature {NONE}
  86. -- Internals
  87. int_background_box (child: POINTER): POINTER
  88. external
  89. "C inline use %"eiffel-iup.h%""
  90. alias
  91. "return IupBackgroundBox ($child);"
  92. end
  93. end
  94. -- The MIT License (MIT)
  95. -- Copyright (c) 2016, 2017, 2019 by German A. Arias
  96. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  97. -- of this software and associated documentation files (the "Software"), to deal
  98. -- in the Software without restriction, including without limitation the rights
  99. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  100. -- copies of the Software, and to permit persons to whom the Software is
  101. -- furnished to do so, subject to the following conditions:
  102. --
  103. -- The above copyright notice and this permission notice shall be included in
  104. -- all copies or substantial portions of the Software.
  105. --
  106. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  107. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  108. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  109. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  110. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  111. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  112. -- SOFTWARE.