iup_text.e 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. class IUP_TEXT
  2. -- Creates an editable text field.
  3. -- When using UTF-8 strings in GTK be aware that all attributes are indexed by
  4. -- characters, NOT by byte index, because some characters in UTF-8 can use more
  5. -- than one byte. This also applies to Windows if FORMATTING=True depending on
  6. -- the Windows codepage (for example East Asian codepage where some characters
  7. -- take two bytes).
  8. inherit
  9. IUP_WIDGET
  10. undefine
  11. execute_spin,
  12. execute_dragbegin,
  13. execute_dragdatasize,
  14. execute_dragdata,
  15. execute_dragend,
  16. execute_dropdata,
  17. execute_dropmotion
  18. redefine
  19. execute_map,
  20. execute_unmap,
  21. execute_destroy,
  22. execute_getfocus,
  23. execute_killfocus,
  24. execute_enterwindow,
  25. execute_leavewindow,
  26. execute_k_any,
  27. execute_help,
  28. execute_action_fnis,
  29. execute_button,
  30. execute_caret,
  31. execute_dropfiles,
  32. execute_motion,
  33. execute_valuechanged,
  34. execute_maskfail
  35. end
  36. IUP_WIDGET_BGCOLOR
  37. IUP_WIDGET_FGCOLOR
  38. IUP_WIDGET_SIZE
  39. IUP_WIDGET_ACTIVE
  40. IUP_WIDGET_FONT
  41. IUP_WIDGET_EXPAND
  42. IUP_WIDGET_SCREENPOSITION
  43. IUP_WIDGET_POSITION
  44. IUP_WIDGET_MAXMIN_SIZE
  45. IUP_WIDGET_TIP
  46. IUP_WIDGET_RASTERSIZE
  47. IUP_WIDGET_USERSIZE
  48. IUP_WIDGET_ZORDER
  49. IUP_WIDGET_VISIBLE
  50. IUP_WIDGET_CHILD
  51. IUP_WIDGET_NAME
  52. IUP_WIDGET_FOCUS
  53. IUP_WIDGET_PROPAGATEFOCUS
  54. IUP_WIDGET_CUSTOM_ATTRIBUTES
  55. IUP_DRAG_AND_DROP
  56. IUP_WIDGET_TEXT_COMMON
  57. IUP_WIDGET_TEXT_SPIN
  58. IUP_WIDGET_TEXT_CARET
  59. IUP_WIDGET_TEXT_SELECTION
  60. create {ANY}
  61. text
  62. feature {ANY}
  63. text
  64. -- A new text field.
  65. local
  66. a_text, p: POINTER
  67. do
  68. a_text := int_text(p)
  69. set_widget(a_text)
  70. end
  71. -- Attributes
  72. set_alignment (value: STRING)
  73. -- [Windows and GTK Only] (non inheritable): text alignment. Possible
  74. -- values: "ALEFT", "ARIGHT", "ACENTER". Default: "ALEFT". In Motif, text
  75. -- is always left aligned.
  76. require
  77. is_valid: is_valid_alignment(value)
  78. do
  79. iup_open.set_attribute(Current, "ALIGNMENT", value)
  80. end
  81. set_border (state: BOOLEAN)
  82. -- (creation only): Shows a border around the text. Default: "True".
  83. do
  84. iup_open.set_attribute(Current, "BORDER", boolean_to_yesno(state))
  85. end
  86. set_can_focus (state: BOOLEAN)
  87. -- (creation only) (non inheritable): enables the focus traversal of the
  88. -- control. In Windows the control will still get the focus when clicked.
  89. -- Default: True.
  90. do
  91. iup_open.set_attribute(Current, "CANFOCUS", boolean_to_yesno(state))
  92. end
  93. set_change_case (value: STRING)
  94. -- (non inheritable): Change case according to given conversion. Can
  95. -- be UPPER, LOWER, TOGGLE, or TITLE. TITLE case change first letter of
  96. -- words separated by spaces to upper case others to lower case, but
  97. -- first letter is changed only if word has more than 3 characters, for
  98. -- instance: "Best of the World". Supports Latin-1 encoding only, even
  99. -- when using UTF-8. Does not depends on current locale.
  100. require
  101. is_valid: is_valid_change_case(value)
  102. do
  103. iup_open.set_attribute(Current, "CHANGECASE", value)
  104. end
  105. get_count: INTEGER
  106. -- (read-only): returns the number of characters in the text, including
  107. -- the line breaks.
  108. local
  109. str: STRING
  110. do
  111. str := iup_open.get_attribute(Current, "COUNT")
  112. if str.is_integer then
  113. Result := str.to_integer
  114. end
  115. end
  116. set_as_drop_files_target (state: BOOLEAN)
  117. -- [Windows and GTK Only] (non inheritable): Enable or disable the drop
  118. -- of files. Default: False, but if DROPFILES_CB is defined when the
  119. -- element is mapped then it will be automatically enabled.
  120. do
  121. iup_open.set_attribute(Current, "DROPFILESTARGET", boolean_to_yesno(state))
  122. end
  123. set_formatting (state: BOOLEAN)
  124. -- [Windows and GTK Only] (non inheritable): When enabled allow the use
  125. -- of text formatting attributes. In GTK is always enabled, but only when
  126. -- MULTILINE=True. Default: False.
  127. do
  128. iup_open.set_attribute(Current, "FORMATTING", boolean_to_yesno(state))
  129. end
  130. add_format_tag (name: STRING)
  131. -- [write only] (non inheritable) Name of a format tag element to be
  132. -- added to the IUP_TEXT. The name association must be done before
  133. -- setting the attribute.
  134. do
  135. iup_open.set_attribute(Current, "ADDFORMATTAG", name)
  136. end
  137. add_format_widget (wgt: IUP_FORMATTING)
  138. -- [write only] (non inheritable) Handle of a format tag element to be
  139. -- added to the IUP_TEXT. The tag element will be automatically destroyed
  140. -- when the IUP_TEXT is mapped. If the IUP_TEXT is already mapped, the
  141. -- format tag is immediately destroyed when the attribute is set. The
  142. -- format tag can NOT be reused.
  143. do
  144. iup_open.set_attribute_handle(Current, "ADDFORMATTAG_HANDLE", wgt)
  145. end
  146. remove_formatting (value: STRING)
  147. -- Removes the formatting of the current selection if YES, and from all
  148. -- text if ALL is used.
  149. require
  150. is_valid_remove(value)
  151. do
  152. iup_open.set_attribute(Current, "REMOVEFORMATTING", value)
  153. end
  154. set_no_hide_sel (state: BOOLEAN)
  155. -- [Windows Only]: do not hide the selection when the control loses its
  156. -- focus. Default: True.
  157. do
  158. iup_open.set_attribute(Current, "NOHIDESEL", boolean_to_yesno(state))
  159. end
  160. set_overwrite (state: BOOLEAN)
  161. -- [Windows and GTK Only] (non inheritable): turns the overwrite mode
  162. -- ON (True) or OFF (False). Works only when FORMATTING=True.
  163. local
  164. str: STRING
  165. do
  166. if state then
  167. str := "ON"
  168. else
  169. str := "OFF"
  170. end
  171. iup_open.set_attribute(Current, "OVERWRITE", str)
  172. end
  173. set_password (state: BOOLEAN)
  174. -- (creation only) [Windows and GTK Only] (non inheritable): Hide the
  175. -- typed character using an "*". Default: "False".
  176. do
  177. iup_open.set_attribute(Current, "PASSWORD", boolean_to_yesno(state))
  178. end
  179. set_value (value: STRING)
  180. -- (non inheritable): Text entered by the user. The '\n' character
  181. -- indicates a new line, valid only when is MULTILINE. After the element
  182. -- is mapped and if there is no text will return the empty string "".
  183. do
  184. iup_open.set_str_attribute(Current, "VALUE", value)
  185. end
  186. get_value: STRING
  187. -- The value.
  188. do
  189. Result := iup_open.get_attribute(Current, "VALUE")
  190. end
  191. set_value_masked (value: STRING)
  192. -- (non inheritable) (write-only): sets VALUE but first checks if it is
  193. -- validated by MASK. If not does nothing.
  194. do
  195. iup_open.set_attribute(Current, "VALUEMASKED", value)
  196. end
  197. set_visible_columns (value: INTEGER)
  198. -- Defines the number of visible columns for the Natural Size, this means
  199. -- that will act also as minimum number of visible columns. It uses a
  200. -- wider character size then the one used for the SIZE attribute so
  201. -- strings will fit better without the need of extra columns. As for SIZE
  202. -- you can set to Void after map to use it as an initial value. Default: 5
  203. require
  204. value >= 0
  205. do
  206. iup_open.set_attribute(Current, "VISIBLECOLUMNS", value.out)
  207. end
  208. -- Coordination to pos
  209. convert_xy_to_pos (x, y: INTEGER): INTEGER
  210. -- Converts a (x,y) coordinate in an string position.
  211. -- Returns: a position in the string starting at 0. If fails returns -1.
  212. -- Position is always "column - 1".
  213. do
  214. Result := iup_open.iup_convert_xy_to_pos (Current, x, y)
  215. end
  216. -- Callbacks
  217. -- Common
  218. set_cb_map (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  219. -- Called right after an element is mapped and its attributes updated.
  220. local
  221. operation: INTEGER
  222. do
  223. cb_map := act
  224. if cb_map /= Void then
  225. operation := 1
  226. else
  227. operation := 0
  228. end
  229. iup_open.set_callback (Current, "MAP_CB", "NONEEDED", operation)
  230. end
  231. set_cb_unmap (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  232. -- Called right before an element is unmapped.
  233. local
  234. operation: INTEGER
  235. do
  236. cb_unmap := act
  237. if cb_unmap /= Void then
  238. operation := 1
  239. else
  240. operation := 0
  241. end
  242. iup_open.set_callback (Current, "UNMAP_CB", "NONEEDED", operation)
  243. end
  244. set_cb_destroy (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  245. -- Called right before an element is destroyed.
  246. local
  247. operation: INTEGER
  248. do
  249. cb_destroy := act
  250. if cb_destroy /= Void then
  251. operation := 1
  252. else
  253. operation := 0
  254. end
  255. iup_open.set_callback (Current, "DESTROY_CB", "NONEEDED", operation)
  256. end
  257. set_cb_get_focus (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  258. -- Action generated when an element is given keyboard focus.
  259. -- This callback is called after the KILLFOCUS_CB of the element
  260. -- that loosed the focus. The {IUP}.get_focus function during the
  261. -- callback returns the element that loosed the focus.
  262. local
  263. operation: INTEGER
  264. do
  265. cb_getfocus := act
  266. if cb_getfocus /= Void then
  267. operation := 1
  268. else
  269. operation := 0
  270. end
  271. iup_open.set_callback (Current, "GETFOCUS_CB", "NONEEDED", operation)
  272. end
  273. set_cb_kill_focus (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  274. -- Action generated when an element loses keyboard focus. This
  275. -- callback is called before the GETFOCUS_CB of the element that
  276. -- gets the focus.
  277. local
  278. operation: INTEGER
  279. do
  280. cb_killfocus := act
  281. if cb_killfocus /= Void then
  282. operation := 1
  283. else
  284. operation := 0
  285. end
  286. iup_open.set_callback (Current, "KILLFOCUS_CB", "NONEEDED", operation)
  287. end
  288. set_cb_enter_window (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  289. -- Action generated when the mouse enters the native element.
  290. local
  291. operation: INTEGER
  292. do
  293. cb_enterwindow := act
  294. if cb_enterwindow /= Void then
  295. operation := 1
  296. else
  297. operation := 0
  298. end
  299. iup_open.set_callback (Current, "ENTERWINDOW_CB", "NONEEDED", operation)
  300. end
  301. set_cb_leave_window (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  302. -- Action generated when the mouse leaves the native element.
  303. local
  304. operation: INTEGER
  305. do
  306. cb_leavewindow := act
  307. if cb_leavewindow /= Void then
  308. operation := 1
  309. else
  310. operation := 0
  311. end
  312. iup_open.set_callback (Current, "LEAVEWINDOW_CB", "NONEEDED", operation)
  313. end
  314. set_cb_k_any (act: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER], STRING])
  315. -- Action generated when a keyboard event occurs.
  316. -- IUP_WIDGET the element that activated the event.
  317. -- INTEGER identifier of typed key. Please refer to the Keyboard
  318. -- Codes table for a list of possible values.
  319. --
  320. -- Returns: If IUP_IGNORE is returned the key is ignored and not
  321. -- processed by the control and not propagated. If returns
  322. -- IUP_CONTINUE, the key will be processed and the event will be
  323. -- propagated to the parent of the element receiving it, this is
  324. -- the default behavior. If returns IUP_DEFAULT the key is processed
  325. -- but it is not propagated. IUP_CLOSE will be processed.
  326. local
  327. operation: INTEGER
  328. do
  329. cb_k_any := act
  330. if cb_k_any /= Void then
  331. operation := 1
  332. else
  333. operation := 0
  334. end
  335. iup_open.set_callback (Current, "K_ANY", "NONEEDED", operation)
  336. end
  337. set_cb_help (act: detachable PROCEDURE[TUPLE[IUP_TEXT]])
  338. -- Action generated when the user press F1 at a control. In Motif
  339. -- is also activated by the Help button in some workstations
  340. -- keyboard.
  341. -- Returns: IUP_CLOSE will be processed.
  342. local
  343. operation: INTEGER
  344. do
  345. cb_help := act
  346. if cb_help /= Void then
  347. operation := 1
  348. else
  349. operation := 0
  350. end
  351. iup_open.set_callback (Current, "HELP_CB", "NONEEDED", operation)
  352. end
  353. -- Extra
  354. set_cb_text (act: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, STRING], STRING])
  355. -- Action generated when the text is edited, but before its value is
  356. -- actually changed. Can be generated when using the keyboard, undo
  357. -- system or from the clipboard.
  358. --
  359. -- ih: identifier of the element that activated the event.
  360. -- c: valid alpha numeric character or 0.
  361. -- new_value: Represents the new text value.
  362. --
  363. -- Returns: IUP_CLOSE will be processed, but the change will be ignored.
  364. -- If IUP_IGNORE, the system will ignore the new value. If c is valid and
  365. -- returns a valid alpha numeric-character, this new character will be
  366. -- used instead. The VALUE attribute can be changed only if IUP_IGNORE is
  367. -- returned.
  368. local
  369. operation: INTEGER
  370. do
  371. cb_action := act
  372. if cb_action /= Void then
  373. operation := 1
  374. else
  375. operation := 0
  376. end
  377. iup_open.set_callback (Current, "ACTION", "Fnis", operation)
  378. end
  379. set_cb_button (act: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING])
  380. -- Action generated when any mouse button is pressed and when it is
  381. -- released. Both calls occur before the ACTION callback when button 1 is
  382. -- being used.
  383. -- Use convert_xy_to_pos to convert (x,y) coordinates in character
  384. -- positioning.
  385. --
  386. -- IUP_BUTTON: identifies the element that activated the event.
  387. -- button: identifies the activated mouse button:
  388. --
  389. -- 1 - left mouse button (button 1);
  390. -- 2 - middle mouse button (button 2);
  391. -- 3 - right mouse button (button 3).
  392. --
  393. -- pressed: indicates the state of the button:
  394. --
  395. -- 0 - mouse button was released;
  396. -- 1 - mouse button was pressed.
  397. --
  398. -- x, y: position in the canvas where the event has occurred, in pixels.
  399. --
  400. -- status: status of the mouse buttons and some keyboard keys at the
  401. -- moment the event is generated. The following IUP features must be used
  402. -- for verification:
  403. --
  404. -- is_shift(status)
  405. -- is_control(status)
  406. -- is_button_1(status)
  407. -- is_button_2(status)
  408. -- is_button_3(status)
  409. -- is_button_4(status)
  410. -- is_button_5(status)
  411. -- is_double(status)
  412. -- is_alt(status)
  413. -- is_sys(status)
  414. --
  415. -- Returns: IUP_CLOSE will be processed. On some controls if IUP_IGNORE
  416. -- is returned the action is ignored (this is system dependent).
  417. local
  418. operation: INTEGER
  419. do
  420. cb_button := act
  421. if cb_button /= Void then
  422. operation := 1
  423. else
  424. operation := 0
  425. end
  426. iup_open.set_callback (Current, "BUTTON_CB", "NONEEDED", operation)
  427. end
  428. set_cb_caret (act: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, INTEGER], STRING])
  429. -- Action generated when the caret/cursor position is changed.
  430. --
  431. -- ih: identifier of the element that activated the event.
  432. -- lin, col: line and column number (start at 1).
  433. -- pos: 0 based character position.
  434. --
  435. -- For single line controls lin is always 1, and pos is always "col-1".
  436. local
  437. operation: INTEGER
  438. do
  439. cb_caret := act
  440. if cb_caret /= Void then
  441. operation := 1
  442. else
  443. operation := 0
  444. end
  445. iup_open.set_callback (Current, "CARET_CB", "NONEEDED", operation)
  446. end
  447. set_cb_drop_files (act: detachable FUNCTION[TUPLE[IUP_TEXT, STRING, INTEGER, INTEGER, INTEGER], STRING])
  448. -- Action called when a file is "dropped" into the control. When several
  449. -- files are dropped at once, the callback is called several times, once
  450. -- for each file.
  451. --
  452. -- If defined after the element is mapped then the attribute
  453. -- DROPFILESTARGET must be set to True. [Windows and GTK Only]
  454. --
  455. -- ih: identifier of the element that activated the event.
  456. -- filename: Name of the dropped file.
  457. -- num: Number index of the dropped file. If several files are dropped,
  458. -- num is the index of the dropped file starting from "total-1" to "0".
  459. -- x: X coordinate of the point where the user released the mouse button.
  460. -- y: Y coordinate of the point where the user released the mouse button.
  461. --
  462. -- Returns: If IUP_IGNORE is returned the callback will NOT be called for
  463. -- the next dropped files, and the processing of dropped files will be
  464. -- interrupted.
  465. local
  466. operation: INTEGER
  467. do
  468. cb_dropfiles := act
  469. if cb_dropfiles /= Void then
  470. operation := 1
  471. else
  472. operation := 0
  473. end
  474. iup_open.set_callback (Current, "DROPFILES_CB", "NONEEDED", operation)
  475. end
  476. set_cb_motion (act: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, STRING], STRING])
  477. -- Action generated when the mouse moves.
  478. -- Use convert_xy_to_pos to convert (x,y) coordinates in character
  479. -- positioning.
  480. --
  481. -- ih: identifier of the element that activated the event.
  482. -- x, y: position in the canvas where the event has occurred, in pixels.
  483. -- status: status of mouse buttons and certain keyboard keys at the
  484. -- moment the event was generated. The same macros used for BUTTON_CB can
  485. -- be used for this status.
  486. local
  487. operation: INTEGER
  488. do
  489. cb_motion := act
  490. if cb_motion /= Void then
  491. operation := 1
  492. else
  493. operation := 0
  494. end
  495. iup_open.set_callback (Current, "MOTION_CB", "NONEEDED", operation)
  496. end
  497. set_cb_value_changed (act: detachable FUNCTION[TUPLE[IUP_TEXT], STRING])
  498. -- Called after the value was interactively changed by the user.
  499. local
  500. operation: INTEGER
  501. do
  502. cb_valuechanged := act
  503. if cb_valuechanged /= Void then
  504. operation := 1
  505. else
  506. operation := 0
  507. end
  508. iup_open.set_callback (Current, "VALUECHANGED_CB", "NONEEDED", operation)
  509. end
  510. set_cb_mask_fail (act: detachable FUNCTION[TUPLE[IUP_TEXT, STRING], STRING])
  511. -- Action generated when the new text fails at the mask check.
  512. -- ih: identifier of the element that activated the event.
  513. -- new_value: Represents the new text value.
  514. local
  515. operation: INTEGER
  516. do
  517. cb_maskfail := act
  518. if cb_maskfail /= Void then
  519. operation := 1
  520. else
  521. operation := 0
  522. end
  523. iup_open.set_callback (Current, "MASKFAIL_CB", "NONEEDED", operation)
  524. end
  525. -- Validations
  526. is_valid_alignment (value: STRING): BOOLEAN
  527. do
  528. if value.is_equal("ALEFT") or
  529. value.is_equal("ACENTER") or
  530. value.is_equal("ARIGHT") then
  531. Result := True
  532. else
  533. Result := False
  534. end
  535. end
  536. is_valid_remove (value: STRING): BOOLEAN
  537. do
  538. if value.is_equal("YES") or
  539. value.is_equal("ALL") then
  540. Result := True
  541. else
  542. Result := False
  543. end
  544. end
  545. is_valid_change_case (value: STRING): BOOLEAN
  546. do
  547. if value.is_equal("UPPER") or
  548. value.is_equal("LOWER") or
  549. value.is_equal("TOGGLE") or
  550. value.is_equal("TITLE") then
  551. Result := True
  552. else
  553. Result := False
  554. end
  555. end
  556. feature {IUP}
  557. execute_map: STRING
  558. do
  559. if attached cb_map as int_cb then
  560. Result := int_cb.item([Current])
  561. else
  562. Result := "IUP_DEFAULT"
  563. end
  564. end
  565. execute_unmap: STRING
  566. do
  567. if attached cb_unmap as int_cb then
  568. Result := int_cb.item([Current])
  569. else
  570. Result := "IUP_DEFAULT"
  571. end
  572. end
  573. execute_destroy: STRING
  574. do
  575. if attached cb_destroy as int_cb then
  576. Result := int_cb.item([Current])
  577. else
  578. Result := "IUP_DEFAULT"
  579. end
  580. end
  581. execute_getfocus: STRING
  582. do
  583. if attached cb_getfocus as int_cb then
  584. Result := int_cb.item([Current])
  585. else
  586. Result := "IUP_DEFAULT"
  587. end
  588. end
  589. execute_killfocus: STRING
  590. do
  591. if attached cb_killfocus as int_cb then
  592. Result := int_cb.item([Current])
  593. else
  594. Result := "IUP_DEFAULT"
  595. end
  596. end
  597. execute_enterwindow: STRING
  598. do
  599. if attached cb_enterwindow as int_cb then
  600. Result := int_cb.item([Current])
  601. else
  602. Result := "IUP_DEFAULT"
  603. end
  604. end
  605. execute_leavewindow: STRING
  606. do
  607. if attached cb_leavewindow as int_cb then
  608. Result := int_cb.item([Current])
  609. else
  610. Result := "IUP_DEFAULT"
  611. end
  612. end
  613. execute_k_any (c: INTEGER): STRING
  614. do
  615. if attached cb_k_any as int_cb then
  616. Result := int_cb.item([Current, c])
  617. else
  618. Result := "IUP_DEFAULT"
  619. end
  620. end
  621. execute_help
  622. do
  623. if attached cb_help as int_cb then
  624. int_cb.call([Current])
  625. end
  626. end
  627. execute_action_fnis (c: INTEGER; new_value: STRING): STRING
  628. do
  629. if attached cb_action as int_cb then
  630. Result := int_cb.item([Current, c, new_value])
  631. else
  632. Result := "IUP_DEFAULT"
  633. end
  634. end
  635. execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
  636. do
  637. if attached cb_button as int_cb then
  638. Result := int_cb.item([Current, btn, pressed, x, y, status])
  639. else
  640. Result := "IUP_DEFAULT"
  641. end
  642. end
  643. execute_caret (lin, col, pos: INTEGER): STRING
  644. do
  645. if attached cb_caret as int_cb then
  646. Result := int_cb.item([Current, lin, col, pos])
  647. else
  648. Result := "IUP_DEFAULT"
  649. end
  650. end
  651. execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
  652. do
  653. if attached cb_dropfiles as int_cb then
  654. Result := int_cb.item([Current, filename, num, x, y])
  655. else
  656. Result := "IUP_DEFAULT"
  657. end
  658. end
  659. execute_motion (x, y: INTEGER; status: STRING): STRING
  660. do
  661. if attached cb_motion as int_cb then
  662. Result := int_cb.item([Current, x, y, status])
  663. else
  664. Result := "IUP_DEFAULT"
  665. end
  666. end
  667. execute_valuechanged: STRING
  668. do
  669. if attached cb_valuechanged as int_cb then
  670. Result := int_cb.item([Current])
  671. else
  672. Result := "IUP_DEFAULT"
  673. end
  674. end
  675. execute_maskfail (new_value: STRING): STRING
  676. do
  677. if attached cb_maskfail as int_cb then
  678. Result := int_cb.item([Current, new_value])
  679. else
  680. Result := "IUP_DEFAULT"
  681. end
  682. end
  683. feature {NONE}
  684. -- For callbacks
  685. cb_map: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  686. cb_unmap: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  687. cb_destroy: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  688. cb_getfocus: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  689. cb_killfocus: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  690. cb_enterwindow: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  691. cb_leavewindow: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  692. cb_k_any: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER], STRING]
  693. cb_help: detachable PROCEDURE[TUPLE[IUP_TEXT]]
  694. cb_action: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, STRING], STRING]
  695. cb_button: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
  696. cb_caret: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, INTEGER], STRING]
  697. cb_dropfiles: detachable FUNCTION[TUPLE[IUP_TEXT, STRING, INTEGER, INTEGER, INTEGER], STRING]
  698. cb_motion: detachable FUNCTION[TUPLE[IUP_TEXT, INTEGER, INTEGER, STRING], STRING]
  699. cb_valuechanged: detachable FUNCTION[TUPLE[IUP_TEXT], STRING]
  700. cb_maskfail: detachable FUNCTION[TUPLE[IUP_TEXT, STRING], STRING]
  701. -- Internals
  702. int_text (action: POINTER): POINTER
  703. external
  704. "C inline use %"eiffel-iup.h%""
  705. alias
  706. "return IupText ($action);"
  707. end
  708. end
  709. -- The MIT License (MIT)
  710. -- Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021 by German A. Arias
  711. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  712. -- of this software and associated documentation files (the "Software"), to deal
  713. -- in the Software without restriction, including without limitation the rights
  714. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  715. -- copies of the Software, and to permit persons to whom the Software is
  716. -- furnished to do so, subject to the following conditions:
  717. --
  718. -- The above copyright notice and this permission notice shall be included in
  719. -- all copies or substantial portions of the Software.
  720. --
  721. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  722. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  723. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  724. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  725. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  726. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  727. -- SOFTWARE.