iup_widget.e 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. class IUP_WIDGET
  2. inherit
  3. ANY
  4. HASHABLE
  5. IUP_GET_POINTER
  6. IUP_INTERFACE
  7. export
  8. {NONE} All
  9. end
  10. create {IUP}
  11. make
  12. feature {IUP}
  13. make
  14. do
  15. -- Just create an IUP_WIDGET not associated with a real widget.
  16. end
  17. feature {ANY}
  18. widget: POINTER
  19. hash_code: INTEGER_32
  20. do
  21. Result := Current.default_pointer.hash_code
  22. end
  23. -- Widget name
  24. set_widget_name (name: STRING)
  25. local
  26. p: POINTER
  27. do
  28. p := int_set_widget_name(get_pointer(name.to_c), widget)
  29. --if p /= default_pointer then
  30. -- io.put_string("There was a previous widget with this name. %N")
  31. --end
  32. end
  33. map: STRING
  34. -- Creates (maps) the native interface objects corresponding to the given
  35. -- IUP interface elements.
  36. --
  37. -- It will also called recursively to create the native element of all
  38. -- the children in the element's tree.
  39. --
  40. -- The element must be already attached to a mapped container, except the
  41. -- dialog. A child can only be mapped if its parent is already mapped.
  42. --
  43. -- This function is automatically called before a dialog is shown in
  44. -- show, show_xy or popup.
  45. --
  46. -- Returns: IUP_NOERROR if successful. If the element was already mapped
  47. -- returns IUP_NOERROR. If the native creation failed returns IUP_ERROR.
  48. local
  49. r: INTEGER
  50. do
  51. r := int_map(widget)
  52. if r.is_equal(0) then
  53. Result := "IUP_NOERROR"
  54. else
  55. Result := "IUP_ERROR"
  56. end
  57. end
  58. unmap
  59. -- Unmap the element from the native system. It will also unmap all its
  60. -- children.
  61. --
  62. -- It will NOT detach the element from its parent, and it will NOT
  63. -- destroy the IUP element.
  64. do
  65. int_unmap(widget);
  66. end
  67. refresh
  68. -- Updates the size and layout of all controls in the same dialog.
  69. do
  70. iup_open.iup_refresh(Current)
  71. end
  72. update_control
  73. -- Mark the element to be redraw when the control returns
  74. -- to the system.
  75. do
  76. iup_open.iup_update(Current)
  77. end
  78. redraw
  79. -- Force the element to be redrawn immediately.
  80. do
  81. iup_open.iup_redraw(Current, 0)
  82. end
  83. destroy
  84. -- Explicitly destroy de IUP widget.
  85. do
  86. iup_open.delete_widget_for_object (widget, Current)
  87. end
  88. -- Theme attributes
  89. set_theme (name: STRING)
  90. -- Applies a set of attributes to a control. The THEME attributes are
  91. -- inheritable.
  92. do
  93. iup_open.set_attribute(Current, "THEME", name)
  94. end
  95. set_ntheme (name: STRING)
  96. -- Like "set_theme" but NOT inheritable.
  97. do
  98. iup_open.set_attribute(Current, "NTHEME", name)
  99. end
  100. feature {IUP} -- Internal handle of callbacks
  101. -- The following should be redefined when appropriate.
  102. -- Common callbacks
  103. execute_map: STRING
  104. do
  105. Result := "IUP_DEFAULT"
  106. end
  107. execute_unmap: STRING
  108. do
  109. Result := "IUP_DEFAULT"
  110. end
  111. execute_destroy: STRING
  112. do
  113. Result := "IUP_DEFAULT"
  114. end
  115. execute_getfocus: STRING
  116. do
  117. Result := "IUP_DEFAULT"
  118. end
  119. execute_killfocus: STRING
  120. do
  121. Result := "IUP_DEFAULT"
  122. end
  123. execute_enterwindow: STRING
  124. do
  125. Result := "IUP_DEFAULT"
  126. end
  127. execute_leavewindow: STRING
  128. do
  129. Result := "IUP_DEFAULT"
  130. end
  131. execute_k_any (c: INTEGER): STRING
  132. do
  133. Result := "IUP_DEFAULT"
  134. end
  135. execute_help
  136. do
  137. -- Nothing to be done.
  138. end
  139. execute_action: STRING
  140. do
  141. Result := "IUP_DEFAULT"
  142. end
  143. -- Dialogs
  144. execute_close: STRING
  145. do
  146. Result := "IUP_DEFAULT"
  147. end
  148. execute_copydata (cmdline: STRING; size: INTEGER): STRING
  149. do
  150. Result := "IUP_DEFAULT"
  151. end
  152. -- Also canvas, label, list, text
  153. execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
  154. do
  155. Result := "IUP_DEFAULT"
  156. end
  157. execute_mdiactivate: STRING
  158. do
  159. Result := "IUP_DEFAULT"
  160. end
  161. execute_move (x: INTEGER; y: INTEGER): STRING
  162. do
  163. Result := "IUP_DEFAULT"
  164. end
  165. -- Also for canvas.
  166. execute_resize (width: INTEGER; height: INTEGER): STRING
  167. do
  168. Result := "IUP_DEFAULT"
  169. end
  170. execute_show (state: STRING): STRING
  171. do
  172. Result := "IUP_DEFAULT"
  173. end
  174. execute_trayclick (but: INTEGER; pressed: INTEGER; dclick: INTEGER): STRING
  175. do
  176. Result := "IUP_DEFAULT"
  177. end
  178. -- File dialog
  179. execute_file (file_name, status: STRING): STRING
  180. do
  181. Result := "IUP_DEFAULT"
  182. end
  183. -- Color dialog
  184. execute_colorupdate: STRING
  185. do
  186. Result := "IUP_DEFAULT"
  187. end
  188. -- Progress bar dialog
  189. execute_cancel: STRING
  190. do
  191. Result := "IUP_DEFAULT"
  192. end
  193. -- Buttons, canvas, label, list, text
  194. execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
  195. do
  196. Result := "IUP_DEFAULT"
  197. end
  198. -- Calendar, also split, text, flat button
  199. execute_valuechanged: STRING
  200. do
  201. Result := "IUP_DEFAULT"
  202. end
  203. -- Canvas
  204. execute_action_fnff (posx, posy: REAL_32): STRING
  205. do
  206. Result := "IUP_DEFAULT"
  207. end
  208. execute_focus (focus: INTEGER): STRING
  209. do
  210. Result := "IUP_DEFAULT"
  211. end
  212. -- Also list, text
  213. execute_motion (x, y: INTEGER; status: STRING): STRING
  214. do
  215. Result := "IUP_DEFAULT"
  216. end
  217. execute_keypress (c, press: INTEGER): STRING
  218. do
  219. Result := "IUP_DEFAULT"
  220. end
  221. execute_scroll (op: INTEGER; posx, posy: REAL_32): STRING
  222. do
  223. Result := "IUP_DEFAULT"
  224. end
  225. execute_wheel (delta: REAL_32; x, y: INTEGER; status: STRING): STRING
  226. do
  227. Result := "IUP_DEFAULT"
  228. end
  229. -- Detach box
  230. execute_detached (new_parent: IUP_DIALOG; x, y: INTEGER): STRING
  231. do
  232. Result := "IUP_DEFAULT"
  233. end
  234. execute_restored (old_parent: IUP_WIDGET; x, y: INTEGER): STRING
  235. do
  236. Result := "IUP_DEFAULT"
  237. end
  238. -- Expander
  239. execute_openclose (state: INTEGER): STRING
  240. do
  241. Result := "IUP_DEFAULT"
  242. end
  243. execute_extrabutton (button, pressed: INTEGER): STRING
  244. do
  245. Result := "IUP_DEFAULT"
  246. end
  247. -- Link
  248. execute_click (url: STRING): STRING
  249. do
  250. Result := "IUP_DEFAULT"
  251. end
  252. -- List
  253. execute_action_fnsii (text: STRING; item, state: INTEGER): STRING
  254. do
  255. Result := "IUP_DEFAULT"
  256. end
  257. -- Also text
  258. execute_caret (lin, col, pos: INTEGER): STRING
  259. do
  260. Result := "IUP_DEFAULT"
  261. end
  262. execute_dblclick (item: INTEGER; text: STRING): STRING
  263. do
  264. Result := "IUP_DEFAULT"
  265. end
  266. execute_dragdrop (drag_id, drop_id, isshift, iscontrol: INTEGER): STRING
  267. do
  268. Result := "IUP_DEFAULT"
  269. end
  270. execute_dropdown (state: INTEGER): STRING
  271. do
  272. Result := "IUP_DEFAULT"
  273. end
  274. execute_edit (c: INTEGER; new_value: STRING): STRING
  275. do
  276. Result := "IUP_DEFAULT"
  277. end
  278. execute_multiselect (value: STRING): STRING
  279. do
  280. Result := "IUP_DEFAULT"
  281. end
  282. -- Spin, Spin box
  283. execute_spin (inc: INTEGER): STRING
  284. do
  285. Result := "IUP_DEFAULT"
  286. end
  287. -- Tabs
  288. execute_tabchange (new_tab, old_tab: IUP_WIDGET): STRING
  289. do
  290. Result := "IUP_DEFAULT"
  291. end
  292. execute_tabchangepos (new_pos, old_pos: INTEGER): STRING
  293. do
  294. Result := "IUP_DEFAULT"
  295. end
  296. execute_tabclose (pos: INTEGER): STRING
  297. do
  298. Result := "IUP_DEFAULT"
  299. end
  300. execute_rightclick (pos: INTEGER): STRING
  301. do
  302. Result := "IUP_DEFAULT"
  303. end
  304. -- Text
  305. execute_action_fnis (c: INTEGER; new_value: STRING): STRING
  306. do
  307. Result := "IUP_DEFAULT"
  308. end
  309. execute_maskfail (new_value: STRING): STRING
  310. do
  311. Result := "IUP_DEFAULT"
  312. end
  313. -- Toggle
  314. execute_action_fni (state: INTEGER): STRING
  315. do
  316. Result := "IUP_DEFAULT"
  317. end
  318. -- Tree
  319. execute_selection (id, status: INTEGER): STRING
  320. do
  321. Result := "IUP_DEFAULT"
  322. end
  323. execute_multiselection (ids: POINTER; n: INTEGER): STRING
  324. do
  325. Result := "IUP_DEFAULT"
  326. end
  327. execute_multiunselection (ids: POINTER; n: INTEGER): STRING
  328. do
  329. Result := "IUP_DEFAULT"
  330. end
  331. execute_branchopen (id: INTEGER): STRING
  332. do
  333. Result := "IUP_DEFAULT"
  334. end
  335. execute_branchclose (id: INTEGER): STRING
  336. do
  337. Result := "IUP_DEFAULT"
  338. end
  339. execute_executeleaf (id: INTEGER): STRING
  340. do
  341. Result := "IUP_DEFAULT"
  342. end
  343. execute_showrename (id: INTEGER): STRING
  344. do
  345. Result := "IUP_DEFAULT"
  346. end
  347. execute_rename (id: INTEGER; title: STRING): STRING
  348. do
  349. Result := "IUP_DEFAULT"
  350. end
  351. execute_noderemoved (userdata: POINTER): STRING
  352. do
  353. Result := "IUP_DEFAULT"
  354. end
  355. execute_togglevalue (id, state: INTEGER): STRING
  356. do
  357. Result := "IUP_DEFAULT"
  358. end
  359. -- Menu item and submenu
  360. execute_highlight: STRING
  361. do
  362. Result := "IUP_DEFAULT"
  363. end
  364. -- Menu
  365. execute_open: STRING
  366. do
  367. Result := "IUP_DEFAULT"
  368. end
  369. execute_menuclose: STRING
  370. do
  371. Result := "IUP_DEFAULT"
  372. end
  373. -- Drag callbacks
  374. execute_dragbegin (x, y: INTEGER): STRING
  375. do
  376. Result := "IUP_DEFAULT"
  377. end
  378. execute_dragdatasize (type: STRING): INTEGER
  379. do
  380. Result := 0
  381. end
  382. execute_dragdata (type: STRING; data: POINTER; size: INTEGER): STRING
  383. do
  384. Result := "IUP_DEFAULT"
  385. end
  386. execute_dragend (action: INTEGER): STRING
  387. do
  388. Result := "IUP_DEFAULT"
  389. end
  390. -- Drop callbacks
  391. execute_dropdata (type: STRING; data: POINTER; size, x, y: INTEGER): STRING
  392. do
  393. Result := "IUP_DEFAULT"
  394. end
  395. execute_dropmotion (x, y: INTEGER; status: STRING): STRING
  396. do
  397. Result := "IUP_DEFAULT"
  398. end
  399. -- Recent file menu callback
  400. execute_recent: STRING
  401. do
  402. Result := "IUP_DEFAULT"
  403. end
  404. -- Get param
  405. execute_param (handle: POINTER; param_index: INTEGER; user_data: POINTER): INTEGER
  406. do
  407. Result := 0
  408. end
  409. -- Flat button
  410. execute_flat_action: STRING
  411. do
  412. Result := "IUP_DEFAULT"
  413. end
  414. execute_flat_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
  415. do
  416. Result := "IUP_DEFAULT"
  417. end
  418. execute_flat_focus (focus: INTEGER): STRING
  419. do
  420. Result := "IUP_DEFAULT"
  421. end
  422. execute_flat_enterwindow: STRING
  423. do
  424. Result := "IUP_DEFAULT"
  425. end
  426. execute_flat_leavewindow: STRING
  427. do
  428. Result := "IUP_DEFAULT"
  429. end
  430. -- Cells
  431. execute_draw (line, column, xmin, xmax, ymin, ymax: INTEGER; canvas: POINTER): STRING
  432. do
  433. Result := "IUP_DEFAULT"
  434. end
  435. execute_height (line: INTEGER): INTEGER
  436. do
  437. Result := 30
  438. end
  439. execute_hspan (line, column: INTEGER): INTEGER
  440. do
  441. Result := 1
  442. end
  443. execute_mouseclick (btn, prd, l, c, x, y: INTEGER; s: STRING): STRING
  444. do
  445. Result := "IUP_DEFAULT"
  446. end
  447. execute_mousemotion (l, c, x, y: INTEGER; r: STRING): STRING
  448. do
  449. Result := "IUP_DEFAULT"
  450. end
  451. execute_ncols: INTEGER
  452. do
  453. Result := 10
  454. end
  455. execute_nlines: INTEGER
  456. do
  457. Result := 10
  458. end
  459. execute_scrolling (l, c: INTEGER): STRING
  460. do
  461. Result := "IUP_DEFAULT"
  462. end
  463. execute_vspan (l, c: INTEGER): INTEGER
  464. do
  465. Result := 1
  466. end
  467. execute_width (c: INTEGER): INTEGER
  468. do
  469. Result := 60
  470. end
  471. -- Color bar
  472. execute_cell (cell: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  473. do
  474. Result := [(0).to_integer_32, (0).to_integer_32, (0).to_integer_32]
  475. end
  476. execute_extended (cell: INTEGER): STRING
  477. do
  478. Result := "IUP_DEFAULT"
  479. end
  480. execute_select (cell, type: INTEGER): STRING
  481. do
  482. Result := "IUP_DEFAULT"
  483. end
  484. execute_switch (prim_cell, sec_cell: INTEGER): STRING
  485. do
  486. Result := "IUP_DEFAULT"
  487. end
  488. -- Matrix
  489. execute_action_fniiiis (key, lin, col, edition: INTEGER; value: STRING): STRING
  490. do
  491. Result := "IUP_DEFAULT"
  492. end
  493. execute_click_fniis (lin, col: INTEGER; status: STRING): STRING
  494. do
  495. Result := "IUP_DEFAULT"
  496. end
  497. execute_colresize (col: INTEGER): STRING
  498. do
  499. Result := "IUP_DEFAULT"
  500. end
  501. execute_release (lin, col: INTEGER; status: STRING): STRING
  502. do
  503. Result := "IUP_DEFAULT"
  504. end
  505. execute_resizematrix (width, height: INTEGER): STRING
  506. do
  507. Result := "IUP_DEFAULT"
  508. end
  509. execute_mousemove (lin, col: INTEGER): STRING
  510. do
  511. Result := "IUP_DEFAULT"
  512. end
  513. execute_enteritem (lin, col: INTEGER): STRING
  514. do
  515. Result := "IUP_DEFAULT"
  516. end
  517. execute_leaveitem (lin, col: INTEGER): STRING
  518. do
  519. Result := "IUP_DEFAULT"
  520. end
  521. execute_scrolltop (lin, col: INTEGER): STRING
  522. do
  523. Result := "IUP_DEFAULT"
  524. end
  525. execute_bgcolor (lin, col: INTEGER; red, green, blue: POINTER): STRING
  526. do
  527. Result := "IUP_DEFAULT"
  528. end
  529. execute_fgcolor (lin, col: INTEGER; red, green, blue: POINTER): STRING
  530. do
  531. Result := "IUP_DEFAULT"
  532. end
  533. execute_font (lin, col: INTEGER): STRING
  534. do
  535. Result := ""
  536. end
  537. execute_type (lin, col: INTEGER): STRING
  538. do
  539. Result := ""
  540. end
  541. execute_dropcheck (lin, col: INTEGER): STRING
  542. do
  543. Result := "IUP_DEFAULT"
  544. end
  545. execute_translatevalue (lin, col: INTEGER; value: STRING): STRING
  546. do
  547. Result := ""
  548. end
  549. execute_togglevalue_fniii (lin, col, status: INTEGER): STRING
  550. do
  551. Result := "IUP_DEFAULT"
  552. end
  553. execute_drop (drop: IUP_DROP; lin, col: INTEGER): STRING
  554. do
  555. Result := "IUP_DEFAULT"
  556. end
  557. execute_menudrop (drop: IUP_DROP; lin, col: INTEGER): STRING
  558. do
  559. Result := "IUP_DEFAULT"
  560. end
  561. execute_dropselect (lin, col: INTEGER; drop: IUP_DROP; t: STRING; i, v: INTEGER): STRING
  562. do
  563. Result := "IUP_DEFAULT"
  564. end
  565. execute_edition (lin, col, mode, update: INTEGER): STRING
  566. do
  567. Result := "IUP_DEFAULT"
  568. end
  569. execute_value (lin, col: INTEGER): STRING
  570. do
  571. Result := ""
  572. end
  573. execute_value_edit (lin, col: INTEGER; newval: STRING): STRING
  574. do
  575. Result := "IUP_DEFAULT"
  576. end
  577. execute_mark (lin, col: INTEGER): INTEGER
  578. do
  579. Result := (0).to_integer_32
  580. end
  581. execute_markedit (lin, col, marked: INTEGER): STRING
  582. do
  583. Result := "IUP_DEFAULT"
  584. end
  585. -- Flat tabs
  586. execute_flat_motion (x, y: INTEGER; status: STRING): STRING
  587. do
  588. Result := "IUP_DEFAULT"
  589. end
  590. -- Drop button
  591. execute_dropshow (state: INTEGER): STRING
  592. do
  593. Result := "IUP_DEFAULT"
  594. end
  595. -- Dial
  596. execute_button_press (angle: REAL_64): STRING
  597. do
  598. Result := "IUP_DEFAULT"
  599. end
  600. execute_button_release (angle: REAL_64): STRING
  601. do
  602. Result := "IUP_DEFAULT"
  603. end
  604. execute_mousemove_fnd (angle: REAL_64): STRING
  605. do
  606. Result := "IUP_DEFAULT"
  607. end
  608. -- Color browser
  609. execute_change (red, green, blue: INTEGER): STRING
  610. do
  611. Result := "IUP_DEFAULT"
  612. end
  613. execute_drag (red, green, blue: INTEGER): STRING
  614. do
  615. Result := "IUP_DEFAULT"
  616. end
  617. feature {NONE}
  618. -- Internal
  619. set_widget (wgt: detachable POINTER)
  620. do
  621. if attached wgt as a_wgt then
  622. widget := a_wgt
  623. iup_open.set_widget_for_object (widget, Current)
  624. end
  625. end
  626. int_set_widget_name(name, wgt: POINTER): POINTER
  627. external
  628. "C inline use %"eiffel-iup.h%""
  629. alias
  630. "return IupSetHandle ($name, $wgt);"
  631. end
  632. int_map(wgt: POINTER): INTEGER
  633. external
  634. "C inline use %"eiffel-iup.h%""
  635. alias
  636. "return IupMap ($wgt);"
  637. end
  638. int_unmap(wgt: POINTER)
  639. external
  640. "C inline use %"eiffel-iup.h%""
  641. alias
  642. "IupUnmap ($wgt);"
  643. end
  644. end
  645. -- The MIT License (MIT)
  646. -- Copyright (c) 2016, 2017, 2019, 2020 by German A. Arias
  647. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  648. -- of this software and associated documentation files (the "Software"), to deal
  649. -- in the Software without restriction, including without limitation the rights
  650. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  651. -- copies of the Software, and to permit persons to whom the Software is
  652. -- furnished to do so, subject to the following conditions:
  653. --
  654. -- The above copyright notice and this permission notice shall be included in
  655. -- all copies or substantial portions of the Software.
  656. --
  657. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  658. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  659. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  660. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  661. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  662. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  663. -- SOFTWARE.