iup_widget_show.e 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. deferred class IUP_WIDGET_SHOW
  2. -- Commands to show dialogs.
  3. inherit
  4. IUP_WIDGET_INTERNALS
  5. insert
  6. IUP_INTERFACE
  7. feature {ANY}
  8. show : STRING
  9. -- Show the dialog at screen, return IUP_NOERROR if successful.
  10. -- If there was an error returns IUP_ERROR.
  11. local
  12. r: INTEGER
  13. do
  14. r := int_show(widget)
  15. if r.is_equal(0) then
  16. Result := "IUP_NOERROR"
  17. else
  18. Result := "IUP_ERROR"
  19. end
  20. end
  21. show_predefined_xy (x, y: STRING): STRING
  22. -- Displays a dialog in a given position on the screen using predefined
  23. -- values. However you can combine a predefined value with an integer (as
  24. -- string). If there was an error returns IUP_ERROR.
  25. --
  26. -- x: The following predefined values can be used:
  27. --
  28. -- IUP_LEFT: Positions the dialog on the left corner of the main screen
  29. -- IUP_CENTER: Horizontally centralizes the dialog on the main screen
  30. -- IUP_RIGHT: Positions the dialog on the right corner of the main screen
  31. -- IUP_MOUSEPOS: Positions the dialog on the mouse position
  32. -- IUP_CENTERPARENT: Horizontally centralizes the dialog relative to its
  33. -- parent
  34. -- IUP_CURRENT: use the current position of the dialog.
  35. --
  36. -- y: The following predefined calues can be used:
  37. --
  38. -- IUP_TOP: Positions the dialog on the top of the main screen
  39. -- IUP_CENTER: Vertically centralizes the dialog on the main screen
  40. -- IUP_BOTTOM: Positions the dialog on the base of the main screen
  41. -- IUP_MOUSEPOS: Positions the dialog on the mouse position
  42. -- IUP_CENTERPARENT: Vertically centralizes the dialog relative to its
  43. -- parent
  44. -- IUP_CURRENT: use the current position of the dialog.
  45. require
  46. is_valid_position(x, y)
  47. do
  48. Result := show_xy(iup_open.position_to_integer(x),
  49. iup_open.position_to_integer(y))
  50. end
  51. show_xy (x, y: INTEGER): STRING
  52. -- Displays a dialog in a given position on the screen. If there was an
  53. -- error returns IUP_ERROR.
  54. --
  55. -- x: horizontal position of the top left corner of the window, relative
  56. -- to the origin of the main screen.
  57. --
  58. -- y: vertical position of the top left corner of the window, relative to
  59. -- the origin of the main screen.
  60. require
  61. x >= 0
  62. y >= 0
  63. local
  64. r: INTEGER
  65. do
  66. r := int_show_xy(widget, x, y)
  67. if r.is_equal(-1) then
  68. Result := "IUP_INVALID"
  69. elseif r.is_equal(0) then
  70. Result := "IUP_NOERROR"
  71. else
  72. Result := "IUP_ERROR"
  73. end
  74. end
  75. feature {}
  76. -- Internals
  77. int_show (dlg: POINTER): INTEGER
  78. external "plug_in"
  79. alias "{
  80. location: "${sys}/plugins"
  81. module_name: "iup"
  82. feature_name: "IupShow"
  83. }"
  84. end
  85. int_show_xy (wdt: POINTER; x, y: INTEGER): INTEGER
  86. external "plug_in"
  87. alias "{
  88. location: "${sys}/plugins"
  89. module_name: "iup"
  90. feature_name: "IupShowXY"
  91. }"
  92. end
  93. -- Validations
  94. is_valid_position (x, y: STRING): BOOLEAN
  95. local
  96. xs, ys: BOOLEAN
  97. do
  98. if x.is_equal("IUP_LEFT") or
  99. x.is_equal("IUP_CENTER") or
  100. x.is_equal("IUP_RIGHT") or
  101. x.is_equal("IUP_MOUSEPOS") or
  102. x.is_equal("IUP_CENTERPARENT") or
  103. x.is_equal("IUP_CURRENT") then
  104. xs := True
  105. elseif x.is_integer and x.to_integer >= 0 then
  106. xs := True
  107. else
  108. xs := False
  109. end
  110. if y.is_equal("IUP_TOP") or
  111. y.is_equal("IUP_CENTER") or
  112. y.is_equal("IUP_BOTTOM") or
  113. y.is_equal("IUP_MOUSEPOS") or
  114. y.is_equal("IUP_CENTERPARENT") or
  115. y.is_equal("IUP_CURRENT") then
  116. ys := True
  117. elseif y.is_integer and y.to_integer >= 0 then
  118. ys := True
  119. else
  120. ys := False
  121. end
  122. if xs and ys then
  123. Result := True
  124. else
  125. Result := False
  126. end
  127. end
  128. end
  129. -- The MIT License (MIT)
  130. -- Copyright (c) 2016, 2017 by German A. Arias
  131. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  132. -- of this software and associated documentation files (the "Software"), to deal
  133. -- in the Software without restriction, including without limitation the rights
  134. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  135. -- copies of the Software, and to permit persons to whom the Software is
  136. -- furnished to do so, subject to the following conditions:
  137. --
  138. -- The above copyright notice and this permission notice shall be included in
  139. -- all copies or substantial portions of the Software.
  140. --
  141. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  142. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  143. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  144. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  145. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  146. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  147. -- SOFTWARE.