iup_font_dialog.e 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. class IUP_FONT_DIALOG
  2. -- Creates the Font Dialog element. It is a predefined dialog for selecting a
  3. -- font.
  4. -- The IUP_FONT_DIALOG is a native pre-defined dialog not altered by
  5. -- iup_set_language.
  6. --
  7. -- In Windows, the dialog will be modal relative only to its parent or to the
  8. -- active dialog.
  9. inherit
  10. IUP_WIDGET
  11. redefine
  12. execute_help
  13. end
  14. IUP_WIDGET_INTERNALS
  15. IUP_WIDGET_TITLE
  16. IUP_WIDGET_POPUP
  17. IUP_WIDGET_ICON
  18. IUP_WIDGET_PARENT_DIALOG
  19. create {ANY}
  20. font_dialog
  21. feature {ANY}
  22. font_dialog
  23. local
  24. a_font_dialog: POINTER
  25. do
  26. a_font_dialog := int_font_dialog
  27. set_widget(a_font_dialog)
  28. end
  29. -- Attributes
  30. set_preview_text (text: STRING)
  31. -- [GTK and Motif only]: the text shown in the preview area. If not
  32. -- defined, the system will provide a default text.
  33. do
  34. iup_open.set_attribute(Current, "PREVIEWTEXT", text)
  35. end
  36. set_color (red, green, blue: INTEGER)
  37. -- [Windows Only]: The initial color value. In Windows the Choose Font
  38. -- dialog allows the user to select a color from a pre-defined list of
  39. -- colors. Since IUP 3.15 must set SHOWCOLOR=True to enable this option.
  40. -- Format: "R G B A". Each component range from 0 to 255.
  41. do
  42. iup_open.set_attribute(Current, "COLOR", rgb_to_string(red,
  43. green,
  44. blue))
  45. end
  46. get_color: TUPLE[INTEGER, INTEGER, INTEGER]
  47. -- [Windows Only] Return the selected value if the user pressed the Ok
  48. -- button. Format: "R G B". Each component range from 0 to 255.
  49. do
  50. Result := iup_open.get_rgb(Current, "COLOR")
  51. end
  52. set_show_color (state: BOOLEAN)
  53. -- [Windows Only] allows the user to select a color from a pre-defined
  54. -- list of colors.
  55. do
  56. iup_open.set_attribute(Current, "SHOWCOLOR", boolean_to_yesno(state))
  57. end
  58. get_status: INTEGER
  59. -- (read-only): defined to "1" if the user pressed the Ok button, "0" if
  60. -- pressed the Cancel button.
  61. local
  62. value: STRING
  63. do
  64. value := iup_open.get_attribute(Current, "STATUS")
  65. if value.is_integer then
  66. Result := value.to_integer
  67. else
  68. Result := 0
  69. end
  70. end
  71. set_value (value: STRING)
  72. -- The initial font value. Has the same format as the font
  73. -- attribute in other widgets.
  74. do
  75. iup_open.set_attribute(Current, "VALUE", value)
  76. end
  77. get_value: STRING
  78. -- The selected font value, returned if the user pressed the Ok button.
  79. do
  80. Result := iup_open.get_attribute(Current, "VALUE")
  81. end
  82. -- Callbacks
  83. set_cb_help (act: detachable PROCEDURE[TUPLE[IUP_FONT_DIALOG]])
  84. -- Action generated when the user press F1 at a control. In Motif
  85. -- is also activated by the Help button in some workstations
  86. -- keyboard.
  87. -- Returns: IUP_CLOSE will be processed.
  88. local
  89. operation: INTEGER
  90. do
  91. cb_help := act
  92. if cb_help /= Void then
  93. operation := 1
  94. else
  95. operation := 0
  96. end
  97. iup_open.set_callback (Current, "HELP_CB", "NONEEDED", operation)
  98. end
  99. feature {IUP}
  100. execute_help
  101. do
  102. if attached cb_help as int_cb then
  103. int_cb.call([Current])
  104. end
  105. end
  106. feature {NONE}
  107. -- For callbacks
  108. cb_help: detachable PROCEDURE[TUPLE[IUP_FONT_DIALOG]]
  109. -- Internal
  110. int_font_dialog: POINTER
  111. external
  112. "C inline use %"eiffel-iup.h%""
  113. alias
  114. "return IupFontDlg ();"
  115. end
  116. end
  117. -- The MIT License (MIT)
  118. -- Copyright (c) 2016, 2017, 2019, 2020 by German A. Arias
  119. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  120. -- of this software and associated documentation files (the "Software"), to deal
  121. -- in the Software without restriction, including without limitation the rights
  122. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  123. -- copies of the Software, and to permit persons to whom the Software is
  124. -- furnished to do so, subject to the following conditions:
  125. --
  126. -- The above copyright notice and this permission notice shall be included in
  127. -- all copies or substantial portions of the Software.
  128. --
  129. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  130. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  131. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  132. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  133. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  134. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  135. -- SOFTWARE.