iup_tree.e 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  1. class IUP_TREE
  2. -- Creates a tree containing nodes of branches or leaves. Both branches and
  3. -- leaves can have an associated text and image.
  4. --
  5. -- The branches can be expanded or collapsed. When a branch is expanded, its
  6. -- immediate children are visible, and when it is collapsed they are hidden.
  7. --
  8. -- The leaves can generate an "executed" or "renamed" actions, branches can
  9. -- only generate a "renamed" action.
  10. --
  11. -- The focus node is the node with the focus rectangle, marked nodes have their
  12. -- background inverted.
  13. inherit
  14. IUP_WIDGET
  15. undefine
  16. execute_dragbegin,
  17. execute_dragdatasize,
  18. execute_dragdata,
  19. execute_dragend,
  20. execute_dropdata,
  21. execute_dropmotion
  22. redefine
  23. execute_map,
  24. execute_unmap,
  25. execute_destroy,
  26. execute_getfocus,
  27. execute_killfocus,
  28. execute_enterwindow,
  29. execute_leavewindow,
  30. execute_k_any,
  31. execute_help,
  32. execute_button,
  33. execute_motion,
  34. execute_dropfiles,
  35. execute_dragdrop,
  36. execute_rightclick,
  37. execute_selection,
  38. execute_multiselection,
  39. execute_multiunselection,
  40. execute_branchopen,
  41. execute_branchclose,
  42. execute_executeleaf,
  43. execute_showrename,
  44. execute_rename,
  45. execute_noderemoved,
  46. execute_togglevalue
  47. end
  48. IUP_WIDGET_BGCOLOR
  49. IUP_WIDGET_EXPAND
  50. IUP_WIDGET_FGCOLOR
  51. IUP_WIDGET_ACTIVE
  52. IUP_WIDGET_FONT
  53. IUP_WIDGET_SCREENPOSITION
  54. IUP_WIDGET_POSITION
  55. IUP_WIDGET_MAXMIN_SIZE
  56. IUP_WIDGET_TIP
  57. IUP_WIDGET_SIZE
  58. IUP_WIDGET_RASTERSIZE
  59. IUP_WIDGET_USERSIZE
  60. IUP_WIDGET_VISIBLE
  61. IUP_WIDGET_ZORDER
  62. IUP_WIDGET_TITLE
  63. IUP_WIDGET_SPACING
  64. redefine
  65. set_spacing
  66. end
  67. IUP_WIDGET_CHILD
  68. IUP_WIDGET_NAME
  69. IUP_WIDGET_FOCUS
  70. IUP_WIDGET_PROPAGATEFOCUS
  71. IUP_DRAG_AND_DROP
  72. IUP_WIDGET_CUSTOM_ATTRIBUTES
  73. create {ANY}
  74. tree
  75. feature {ANY}
  76. tree
  77. -- A new tree
  78. local
  79. a_tree: POINTER
  80. do
  81. a_tree := int_tree
  82. set_widget(a_tree)
  83. end
  84. -- General attributes
  85. set_add_expanded (state: BOOLEAN)
  86. -- (non inheritable): Defines if branches will be expanded when created.
  87. -- The branch will be actually expanded when it receives the first child.
  88. -- Possible values: "True" = The branches will be created expanded;
  89. -- "False" = The branches will be created collapsed. Default: "True".
  90. do
  91. iup_open.set_attribute(Current, "ADDEXPANDED", boolean_to_yesno(state))
  92. end
  93. set_add_root (state: BOOLEAN)
  94. -- (non inheritable): automatically adds an empty branch as the first
  95. -- node when the tree is mapped. Default: "True".
  96. do
  97. iup_open.set_attribute(Current, "ADDROOT", boolean_to_yesno(state))
  98. end
  99. set_auto_redraw (state: BOOLEAN)
  100. -- [Windows] (non inheritable): automatically redraws the tree when
  101. -- something has change. Set to False to add many items to the tree
  102. -- without updating the display. Default: "True".
  103. do
  104. iup_open.set_attribute(Current, "AUTOREDRAW", boolean_to_yesno(state))
  105. end
  106. set_can_focus (state: BOOLEAN)
  107. -- (creation only) (non inheritable): enables the focus traversal of the
  108. -- control. In Windows the control will still get the focus when clicked.
  109. -- Default: True.
  110. do
  111. iup_open.set_attribute(Current, "CANFOCUS", boolean_to_yesno(state))
  112. end
  113. set_drag_drop_tree (state: BOOLEAN)
  114. -- (non inheritable): enable or disable the drag and drop of nodes
  115. -- between trees, in the same IUP application. Drag & Drop attributes
  116. -- must be set in order to activate the drag & drop support. On the other
  117. -- hand, it is not necessary to register drag & drop callbacks.
  118. -- Default: False.
  119. do
  120. iup_open.set_attribute(Current, "DRAGDROPTREE", boolean_to_yesno(state))
  121. end
  122. set_as_drop_files_target (state: BOOLEAN)
  123. -- [Windows and GTK Only] (non inheritable): Enable or disable the drop
  124. -- of files. Default: False, but if DROPFILES_CB is defined when the
  125. -- element is mapped then it will be automatically enabled. This is NOT
  126. -- related to the drag&drop of nodes inside the tree.
  127. do
  128. iup_open.set_attribute(Current, "DROPFILESTARGET", boolean_to_yesno(state))
  129. end
  130. set_drop_equal_drag (state: BOOLEAN)
  131. -- (non inheritable): if enabled will allow a drop node to be equal to
  132. -- the drag node. Used only if SHOWDRAGDROP = True. In the case the nodes
  133. -- are equal the callback return value is ignored and nothing is done
  134. -- after.
  135. do
  136. iup_open.set_attribute(Current, "DROPEQUALDRAG", boolean_to_yesno(state))
  137. end
  138. set_empty_as_3state (state: BOOLEAN)
  139. -- (non inheritable) [Windows Only]: when SHOWTOGGLE=True, the empty
  140. -- space left in nodes that NODEVISIBLEid=False is filled with the image
  141. -- of the 3state toggle. Can be True or False. Default: False.
  142. do
  143. iup_open.set_attribute(Current, "EMPTYAS3STATE", boolean_to_yesno(state))
  144. end
  145. set_hide_buttons (state: BOOLEAN)
  146. -- (creation only): hide the expand and collapse buttons. In GTK,
  147. -- branches will be only expanded programmatically. In Motif it did not
  148. -- work and crash the test.
  149. do
  150. iup_open.set_attribute(Current, "HIDEBUTTONS", boolean_to_yesno(state))
  151. end
  152. set_hide_lines (state: BOOLEAN)
  153. -- (creation only): hide the lines that connect the nodes in the
  154. -- hierarchy.
  155. do
  156. iup_open.set_attribute(Current, "HIDELINES", boolean_to_yesno(state))
  157. end
  158. set_rgb_highlight_color (red: INTEGER; green: INTEGER; blue: INTEGER)
  159. -- [Windows and Motif Only] (non inheritable): the background color of
  160. -- the selected node. Default: TXTHLCOLOR global attribute.
  161. do
  162. iup_open.set_attribute(Current, "HLCOLOR", rgb_to_string(red, green, blue))
  163. end
  164. set_hexadecimal_highlight_color (color: STRING)
  165. -- Same as set_rgb_hlcolor but usign an hexadecimal
  166. -- value (#RRGGBB).
  167. local
  168. tup: TUPLE[INTEGER, INTEGER, INTEGER]
  169. do
  170. tup := hexadecimal_to_rgb(color)
  171. set_rgb_highlight_color(tup.item_1, tup.item_2, tup.item_3)
  172. end
  173. reset_highlight_color
  174. -- Reset the background color of the selected node.
  175. do
  176. iup_open.reset_attribute(Current, "HLCOLOR")
  177. end
  178. set_indentation (value: INTEGER)
  179. -- Sets the indentation level in pixels. The visual effect of changing
  180. -- the indentation is highly system dependent. In GTK it acts as an
  181. -- additional indent value, and the lines do not follow the extra indent.
  182. -- In Windows is limited to a minimum of 5 pixels.
  183. require
  184. value >= 0
  185. do
  186. iup_open.set_attribute(Current, "INDENTATION", value.to_string)
  187. end
  188. set_info_tip (state: BOOLEAN)
  189. -- [Windows Only]: the TIP is shown every time an item is highlighted.
  190. -- This is the default behavior for TIPs in native tree controls in
  191. -- Windows, if set to False then it will use the regular TIP behavior.
  192. -- Default: True.
  193. do
  194. iup_open.set_attribute(Current, "INFOTIP", boolean_to_yesno(state))
  195. end
  196. set_show_drag_drop (state: BOOLEAN)
  197. -- (creation only) (non inheritable): Enables the internal drag and drop
  198. -- of nodes, and enables the DRAGDROP_CB callback. Default: "False".
  199. -- Works only if MARKMODE=SINGLE.
  200. do
  201. iup_open.set_attribute(Current, "SHOWDRAGDROP", boolean_to_yesno(state))
  202. end
  203. set_show_toggle (state: STRING)
  204. -- (creation only) (non inheritable): enables the use of toggles for all
  205. -- nodes of the tree. Can be "YES", "3STATE" or NO". Default: "NO". In
  206. -- Motif Versions 2.1.x and 2.2.x, the images are disabled (toggle and
  207. -- text only are drawn in nodes of the tree).
  208. do
  209. iup_open.set_attribute(Current, "SHOWTOGGLE", state)
  210. end
  211. set_spacing (value: INTEGER)
  212. -- vertical internal padding for each node. Notice that the distance
  213. -- between each node will be actually 2x the spacing.
  214. do
  215. Precursor (value)
  216. end
  217. set_top_item (value: INTEGER)
  218. -- (write-only): position the given node identifier at the top of the
  219. -- tree or near to make it visible. If any parent node is collapsed then
  220. -- they are automatically expanded.
  221. do
  222. iup_open.set_attribute(Current, "TOPITEM", value.to_string)
  223. end
  224. -- Attributes for nodes
  225. get_count: INTEGER
  226. -- (read only) (non inheritable): returns the total number of nodes in
  227. -- the tree.
  228. local
  229. str: STRING
  230. do
  231. str := iup_open.get_attribute(Current, "COUNT")
  232. if str.is_integer then
  233. Result := str.to_integer
  234. end
  235. end
  236. get_child_count_at (id: INTEGER): INTEGER
  237. require
  238. id >= 0
  239. local
  240. str: STRING
  241. do
  242. str := iup_open.get_attribute_id(Current, "CHILDCOUNT", id)
  243. if str.is_integer then
  244. Result := str.to_integer
  245. end
  246. end
  247. get_total_child_count_at (id: INTEGER): INTEGER
  248. -- (read only): returns the total children count of the specified branch.
  249. -- It counts all grandchildren.
  250. require
  251. id >= 0
  252. local
  253. str: STRING
  254. do
  255. str := iup_open.get_attribute_id(Current, "TOTALCHILDCOUNT", id)
  256. if str.is_integer then
  257. Result := str.to_integer
  258. end
  259. end
  260. get_root_count: INTEGER
  261. -- Returns the number of root nodes.
  262. local
  263. str: STRING
  264. do
  265. str := iup_open.get_attribute(Current, "ROOTCOUNT")
  266. if str.is_integer then
  267. Result := str.to_integer
  268. end
  269. end
  270. set_rgb_color_at (red, green, blue, id: INTEGER;)
  271. -- Text foreground color of the specified node. The value should be a
  272. -- string in the format "R G B"
  273. require
  274. id >= 0
  275. do
  276. iup_open.set_attribute_id(Current, "COLOR", id, rgb_to_string(red, green, blue))
  277. end
  278. get_depth_at (id: INTEGER): INTEGER
  279. -- (read only): returns the depth of the specified node. The first node
  280. -- has depth=0, its immediate children has depth=1, their children has
  281. -- depth=2 and so on.
  282. require
  283. id >= 0
  284. local
  285. str: STRING
  286. do
  287. str := iup_open.get_attribute_id(Current, "DEPTH", id)
  288. if str.is_integer then
  289. Result := str.to_integer
  290. end
  291. end
  292. get_kind_at (id: INTEGER): STRING
  293. -- (read only): returns the kind of the specified node. Possible values:
  294. --
  295. -- "LEAF": The node is a leaf
  296. -- "BRANCH": The node is a branch
  297. require
  298. id >= 0
  299. do
  300. Result := iup_open.get_attribute_id(Current, "KIND", id)
  301. end
  302. get_parent_at (id: INTEGER): INTEGER
  303. -- (read only): returns the identifier of the specified node.
  304. require
  305. id >= 0
  306. local
  307. str: STRING
  308. do
  309. str := iup_open.get_attribute_id(Current, "PARENT", id)
  310. if str.is_integer then
  311. Result := str.to_integer
  312. end
  313. end
  314. get_next_at (id: INTEGER): STRING
  315. -- Returns the next brother (same depth) of the specified node. Returns
  316. -- an empty string if at last child node of the parent (at the same
  317. -- depth).
  318. require
  319. id >= 0
  320. do
  321. Result := iup_open.get_attribute_id(Current, "NEXT", id)
  322. end
  323. get_previous_at (id: INTEGER): STRING
  324. -- Returns the previous brother (same depth) of the specified node.
  325. -- Returns an empty string if at first child node of the parent (at the
  326. -- same depth).
  327. require
  328. id >= 0
  329. do
  330. Result := iup_open.get_attribute_id(Current, "PREVIOUS", id)
  331. end
  332. get_last_at (id: INTEGER): STRING
  333. -- Returns the last brother (same depth) of the specified node.
  334. require
  335. id >= 0
  336. do
  337. Result := iup_open.get_attribute_id(Current, "LAST", id)
  338. end
  339. get_first_at (id: INTEGER): STRING
  340. -- Returns the first brother (same depth) of the specified node. This is
  341. -- the same as getting the first child of the parent of the given node.
  342. require
  343. id >= 0
  344. do
  345. Result := iup_open.get_attribute_id(Current, "FIRST", id)
  346. end
  347. set_state_at (state: STRING; id: INTEGER)
  348. require
  349. is_valid_state(state)
  350. id >= 0
  351. do
  352. iup_open.set_attribute_id(Current, "STATE", id, state)
  353. end
  354. get_state_at (id: INTEGER): STRING
  355. -- The state of the specified branch. Returns Void for a LEAF.
  356. require
  357. id >= 0
  358. do
  359. Result := iup_open.get_attribute_id(Current, "STATE", id)
  360. end
  361. set_title_at (title: STRING; id: INTEGER)
  362. -- The text label of the specified node.
  363. require
  364. id >= 0
  365. do
  366. iup_open.set_attribute_id(Current, "TITLE", id, title)
  367. end
  368. get_title_at (id: INTEGER): STRING
  369. -- The text label of the specified node.
  370. require
  371. id >= 0
  372. do
  373. Result := iup_open.get_attribute_id(Current, "TITLE", id)
  374. end
  375. set_title_font_at (font: STRING; id: INTEGER)
  376. -- The text font of the specified node. The format is the same
  377. -- used at set_font.
  378. require
  379. id >= 0
  380. do
  381. iup_open.set_attribute_id(Current, "TITLEFONT", id, font)
  382. end
  383. set_title_font_style_at (style: STRING; id: INTEGER)
  384. -- Changes the font style of the specified node.
  385. require
  386. id >= 0
  387. do
  388. iup_open.set_attribute_id(Current, "TITLEFONTSTYLE", id, style)
  389. end
  390. set_title_font_size_at (size, id: INTEGER)
  391. -- Changes the font size of the specified node.
  392. require
  393. size > 0
  394. id >= 0
  395. do
  396. iup_open.set_attribute_id(Current, "TITLEFONTSIZE", id, size.to_string)
  397. end
  398. set_toggle_value_at (value: STRING; id: INTEGER)
  399. -- (non inheritable): defines the toggle state. Values can be "ON" or
  400. --"OFF". If SHOW3STATE=True then can also be "NOTDEF". Default: "OFF".
  401. require
  402. is_valid_toggle (value)
  403. id >= 0
  404. do
  405. iup_open.set_attribute_id(Current, "VALUE", id, value)
  406. end
  407. set_toggle_visible_at (state: BOOLEAN; id: INTEGER)
  408. -- (non inheritable): defines the toggle visible state.
  409. -- Default: "True".
  410. require
  411. id >= 0
  412. do
  413. iup_open.set_attribute_id(Current, "TOGGLEVISIBLE", id, boolean_to_yesno(state))
  414. end
  415. set_user_data_at (data: STRING; id: INTEGER)
  416. -- The user data associated with the specified node.
  417. require
  418. id >= 0
  419. do
  420. iup_open.set_attribute_id(Current, "USERDATA", id, data)
  421. end
  422. get_user_data_at (id: INTEGER): STRING
  423. -- The user data associated with the specified node.
  424. require
  425. id >= 0
  426. do
  427. Result := iup_open.get_attribute_id(Current, "USERDATA", id)
  428. end
  429. -- Attributes for images
  430. set_image_at (image: STRING; id: INTEGER)
  431. -- (write only): image name to be used in the specified node, where id is
  432. -- the specified node identifier. Use set_attribute_handle to associate
  433. -- an image to a name. See also IUP_IMAGE. In Windows and Motif set the
  434. -- BGCOLOR attribute before setting the image. If node is a branch it is
  435. -- used when collapsed.
  436. require
  437. id >= 0
  438. do
  439. iup_open.set_attribute_id(Current, "IMAGE", id, image)
  440. end
  441. set_image_expanded_at (image: STRING; id: INTEGER)
  442. -- (write only): same as the IMAGE attribute but used for expanded
  443. -- branches.
  444. require
  445. id >= 0
  446. do
  447. iup_open.set_attribute_id(Current, "IMAGEEXPANDED", id, image)
  448. end
  449. set_image_leaf(image: STRING)
  450. -- The image name that will be shown for all leaves. Default: "IMGLEAF".
  451. -- Internal values "IMGBLANK" and "IMGPAPER" are also available. If
  452. -- BGCOLOR is set the image is automatically updated.
  453. do
  454. iup_open.set_attribute(Current, "IMAGELEAF", image)
  455. end
  456. set_image_branch_collapsed (image: STRING)
  457. -- The image name that will be shown for all collapsed branches.
  458. -- Default: "IMGCOLLAPSED". If BGCOLOR is set the image is automatically
  459. -- updated.
  460. do
  461. iup_open.set_attribute(Current, "IMAGEBRANCHCOLLAPSED", image)
  462. end
  463. set_image_branch_expanded (image: STRING)
  464. -- The image name that will be shown for all expanded branches.
  465. -- Default: "IMGEXPANDED". If BGCOLOR is set the image is automatically
  466. -- updated.
  467. do
  468. iup_open.set_attribute(Current, "IMAGEBRANCHEXPANDED", image)
  469. end
  470. -- Attributes for node
  471. set_value (id: INTEGER)
  472. -- (non inheritable): The focus node identifier. When changed and
  473. -- MARKMODE=SINGLE the node is also selected. The tree is always scrolled
  474. -- so the node becomes visible. In Motif the tree will also receive the
  475. -- focus.
  476. require
  477. id >= 0
  478. do
  479. iup_open.set_attribute(Current, "VALUE", id.to_string)
  480. end
  481. get_value: INTEGER
  482. -- (non inheritable): The focus node identifier. When retrieved but
  483. -- there isn't a node with focus it returns 0 if there are any nodes, and
  484. -- returns -1 if there are no nodes.
  485. local
  486. str: STRING
  487. do
  488. str := iup_open.get_attribute(Current, "VALUE")
  489. if str.is_integer then
  490. Result := str.to_integer
  491. end
  492. end
  493. -- Special operations for nodes
  494. select_first
  495. -- The first node.
  496. do
  497. iup_open.set_attribute(Current, "VALUE", "FIRST")
  498. end
  499. select_last
  500. -- The last node.
  501. do
  502. iup_open.set_attribute(Current, "VALUE", "LAST")
  503. end
  504. select_next
  505. -- The next node.
  506. do
  507. iup_open.set_attribute(Current, "VALUE", "NEXT")
  508. end
  509. select_previous
  510. -- The previous node.
  511. do
  512. iup_open.set_attribute(Current, "VALUE", "PREVIOUS")
  513. end
  514. select_page_down
  515. -- The next visible node, ten nodes after the focus node. If at the last
  516. -- does nothing.
  517. do
  518. iup_open.set_attribute(Current, "VALUE", "PGDN")
  519. end
  520. select_page_up
  521. -- The previous visible node, ten nodes before the focus node. If at the
  522. -- first does nothing.
  523. do
  524. iup_open.set_attribute(Current, "VALUE", "PGUP")
  525. end
  526. clear
  527. -- Clears the selection of the focus node.
  528. do
  529. iup_open.set_attribute(Current, "VALUE", "CLEAR")
  530. end
  531. -- Attributes to marks
  532. set_mark (first, last: INTEGER)
  533. -- (write only) (non inheritable): Selects a range of nodes in the
  534. -- format "first-last". Allowed only when MARKMODE=MULTIPLE.
  535. require
  536. first >= 0
  537. last >= 0
  538. local
  539. str: STRING
  540. do
  541. str := first.to_string
  542. str.append_string("-")
  543. str.append_string(last.to_string
  544. )
  545. iup_open.set_attribute(Current, "MARK", str)
  546. end
  547. invert_mark_at (id: INTEGER)
  548. -- Inverts the specified node selected state, where id is the specified
  549. -- node identifier. If id is empty or invalid, then the focus node is
  550. -- used as reference node.
  551. require
  552. id >= 0
  553. local
  554. str: STRING
  555. do
  556. str := "INVERT"
  557. str.append_string(id.to_string)
  558. iup_open.set_attribute(Current, "MARK", str)
  559. end
  560. mark_block
  561. -- Selects all nodes between the focus node and the initial block-marking
  562. -- node defined by set_mark_start.
  563. do
  564. iup_open.set_attribute(Current, "MARK", "BLOCK")
  565. end
  566. clear_all
  567. -- Clear the selection of all nodes.
  568. do
  569. iup_open.set_attribute(Current, "MARK", "CLEARALL")
  570. end
  571. mark_all
  572. -- Selects all nodes.
  573. do
  574. iup_open.set_attribute(Current, "MARK", "MARKALL")
  575. end
  576. invert_all
  577. -- Inverts the selection of all nodes.
  578. do
  579. iup_open.set_attribute(Current, "MARK", "INVERTALL")
  580. end
  581. set_marked_at (state: BOOLEAN; id: INTEGER)
  582. -- (non inheritable): The selection state of the specified node, where id
  583. -- is the specified node identifier. If id is empty or invalid, then the
  584. -- focus node is used as reference node. State can be: True or False.
  585. -- Default: False.
  586. require
  587. id >= 0
  588. do
  589. iup_open.set_attribute_id(Current, "MARKED", id, boolean_to_yesno(state))
  590. end
  591. get_marked_at (id: INTEGER): BOOLEAN
  592. -- Get the marked state at the specified node.
  593. local
  594. str: STRING
  595. do
  596. str := iup_open.get_attribute_id(Current, "MARKED", id)
  597. Result := yesno_to_boolean(str)
  598. end
  599. set_marked_nodes (value: STRING)
  600. -- (non inheritable): The selection state of all nodes when
  601. -- MARKMODE=MULTIPLE. It accepts a sequence of '+' and '-' symbols
  602. -- indicating the state of each item ('+'=selected, '-'=unselected. When
  603. -- setting this value, if the number of specified symbols is smaller than
  604. -- the total count then the remaining nodes will not be changed.
  605. do
  606. iup_open.set_attribute(Current, "MARKEDNODES", value)
  607. end
  608. get_marked_nodes: STRING
  609. -- The selection state of the nodes. It is a sequence of '+' and '-'
  610. -- symbols indicating the state of each item ('+'=selected,
  611. -- '-'=unselected.
  612. do
  613. Result := iup_open.get_attribute(Current, "MARKEDNODES")
  614. end
  615. set_mark_mode (value: STRING)
  616. -- Defines how the nodes can be selected. Can be: SINGLE or MULTIPLE.
  617. -- Default: SINGLE.
  618. require
  619. is_valid_mode(value)
  620. do
  621. iup_open.set_attribute(Current, "MARKMODE", value)
  622. end
  623. set_mark_start (id: INTEGER)
  624. -- (non inheritable): Defines the initial node for the block marking, used
  625. -- in mark_block. The value must be the node identifier. Default: 0
  626. -- (first node).
  627. require
  628. id >= 0
  629. do
  630. iup_open.set_attribute(Current, "MARKSTART", id.to_string)
  631. end
  632. set_mark_when_toggle (state: BOOLEAN)
  633. -- (non inheritable) [GTK and Windows Only]: selects or clears the
  634. -- selection of a node when its toggle is changed. Works only if the node
  635. -- has a toggle. Default: False.
  636. do
  637. iup_open.set_attribute(Current, "MARKWHENTOGGLE", boolean_to_yesno(state))
  638. end
  639. -- Hierarchy attributes
  640. add_leaf_at (value: STRING; id: INTEGER)
  641. -- (write only): Adds a new leaf after the reference node, where id is
  642. -- the reference node identifier. Use id = -1 to add before the first
  643. -- node. The value is used as the text label of the new node. The id of
  644. -- the new node will be the id of the reference node + 1. The attribute
  645. -- LASTADDNODE is set to the new id. The reference node is marked and all
  646. -- others unmarked. The reference node position remains the same. If the
  647. -- reference node does not exist, nothing happens. If the reference node
  648. -- is a branch then the depth of the new node is one depth increment from
  649. -- the depth of the reference node, if the reference node is a leaf then
  650. -- the new node has the same depth. If you need to add a node after a
  651. -- specified node but at a different depth use insert_leaf_at. Ignored if
  652. -- set before map.
  653. require
  654. id >= -2
  655. do
  656. iup_open.set_attribute_id(Current, "ADDLEAF", id, value)
  657. end
  658. get_last_added_node: INTEGER
  659. -- The id of tha last added node.
  660. local
  661. str: STRING
  662. do
  663. str := iup_open.get_attribute(Current, "LASTADDNODE")
  664. if str.is_integer then
  665. Result := str.to_integer
  666. end
  667. end
  668. add_branch_at (value: STRING; id: INTEGER)
  669. -- (write only): Same as add_leaf_at for branches. Branches can be
  670. -- created expanded or collapsed depending on set_add_expanded. Ignored
  671. -- if set before map.
  672. require
  673. id >= -2
  674. do
  675. iup_open.set_attribute_id(Current, "ADDBRANCH", id, value)
  676. end
  677. copy_node_to (node_id, target_id: INTEGER)
  678. -- (write only): Copies a node and its children, where node_id is the
  679. -- specified node identifier. The target_id is the destination node
  680. -- identifier. If the destination node is a branch and it is expanded,
  681. -- then the specified node is inserted as the first child of the
  682. -- destination node. If the branch is not expanded or the destination
  683. -- node is a leaf, then it is inserted as the next brother of the leaf.
  684. -- The specified node is not changed. All node attributes are copied,
  685. -- except user data. Ignored if set before map.
  686. require
  687. node_id >= 0
  688. target_id >= 0
  689. do
  690. iup_open.set_attribute_id(Current, "COPYNODE", node_id, target_id.to_string)
  691. end
  692. delete_all_nodes
  693. -- Deletes all nodes.
  694. do
  695. iup_open.set_attribute_id(Current, "DELNODE", 1, "ALL")
  696. end
  697. delete_node_at (id: INTEGER)
  698. -- Deletes the specified node and its children (if any).
  699. require
  700. id >= 0
  701. do
  702. iup_open.set_attribute_id(Current, "DELNODE", id, "SELECTED")
  703. end
  704. delete_node_children_at (id: INTEGER)
  705. -- Deletes only the children of the specified node.
  706. require
  707. id >= 0
  708. do
  709. iup_open.set_attribute_id(Current, "DELNODE", id, "CHILDREN")
  710. end
  711. delete_selected_nodes
  712. -- Deletes all the selected nodes (and all their children),
  713. do
  714. iup_open.set_attribute_id(Current, "DELNODE", 1, "MARKED")
  715. end
  716. expand_all
  717. -- (write only): expand all nodes.
  718. do
  719. iup_open.set_attribute(Current, "EXPANDALL", "YES")
  720. end
  721. contract_all
  722. -- (write only): contracts all nodes.
  723. do
  724. iup_open.set_attribute(Current, "EXPANDALL", "NO")
  725. end
  726. insert_leaf_at (value: STRING; id: INTEGER)
  727. -- (write only): Same as add_leaf but the depth of the new node is always
  728. -- the same of the reference node. If the reference node is a leaf, then
  729. -- the id of the new node will be the id of the reference node + 1. If
  730. -- the reference node is a branch the id of the new node will be the id
  731. -- of the reference node + 1 + the total number of child nodes of the
  732. -- reference node.
  733. require
  734. id >= -2
  735. do
  736. iup_open.set_attribute_id(Current, "INSERTLEAF", id, value)
  737. end
  738. insert_branch_at (value: STRING; id: INTEGER)
  739. -- (write only): Same as insert_leaf_at for branches. Branches can be
  740. -- created expanded or collapsed depending on set_add_expanded. Ignored
  741. -- if set before map.
  742. require
  743. id >= -2
  744. do
  745. iup_open.set_attribute_id(Current, "INSERTBRANCH", id, value)
  746. end
  747. move_node_at (node_id, target_id: INTEGER)
  748. -- (write only): Moves a node and its children, where node_id is the
  749. -- specified node identifier. The target_id is the destination node
  750. -- identifier. If the destination node is a branch and it is expanded,
  751. -- then the specified node is inserted as the first child of the
  752. -- destination node. If the branch is not expanded or the destination
  753. -- node is a leaf, then it is inserted as the next brother of the leaf.
  754. -- The specified node is removed. User data and all node attributes are
  755. -- preserved. Ignored if set before map.
  756. require
  757. node_id >= 0
  758. target_id >= 0
  759. do
  760. iup_open.set_attribute_id(Current, "MOVENODE", node_id, target_id.to_string)
  761. end
  762. -- Editing attributes
  763. start_rename
  764. -- (write only): Forces a rename action to take place. Valid only when
  765. -- set_show_rename = True.
  766. do
  767. iup_open.set_attribute(Current, "RENAME", "YES")
  768. end
  769. set_rename_position (position: INTEGER)
  770. -- (write only): the caret’s position of the text box when in-place
  771. -- renaming. The first position is "1". Used only once after
  772. -- SHOWRENAME_CB is called and before the text box is shown.
  773. require
  774. position >= 1
  775. do
  776. iup_open.set_attribute(Current, "RENAMEPOSITION", position.to_string)
  777. end
  778. set_rename_selection (col1, col2: INTEGER)
  779. -- (write only): the selection interval of the text box when in-place
  780. -- renaming. Used only once after SHOWRENAME_CB is called and before the
  781. -- text box is shown.
  782. --
  783. -- Selection interval in characters. Where col1 and col2 are integer
  784. -- numbers corresponding to the selection's interval. col2 correspond to
  785. -- the character after the last selected character.
  786. -- In Windows, when changing the selection the caret position is also
  787. -- changed.
  788. local
  789. str: STRING
  790. do
  791. create str.copy(col1.to_string)
  792. str.append_string(":")
  793. str.append_string(col2.to_string)
  794. iup_open.set_attribute(Current, "RENAMESELECTION", str)
  795. end
  796. set_show_rename (state: BOOLEAN)
  797. -- (creation in Windows) (non inheritable): Allows the in place rename of
  798. -- a node. Default: "False". Since IUP 3.0, F2 and clicking twice only
  799. -- starts to rename a node if SHOWRENAME=True. In Windows must be set to
  800. -- True before map, but can be changed later.
  801. do
  802. iup_open.set_attribute(Current, "SHOWRENAME", boolean_to_yesno(state))
  803. end
  804. -- Coordination to pos
  805. convert_xy_to_pos (x, y: INTEGER): INTEGER
  806. -- Converts a (x,y) coordinate in a node position.
  807. -- Returns: a node identifier starting at 0. If fails returns -1.
  808. do
  809. Result := iup_open.iup_convert_xy_to_pos (Current, x, y)
  810. end
  811. -- Callbacks
  812. -- Common
  813. set_cb_map (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  814. -- Called right after an element is mapped and its attributes updated.
  815. local
  816. operation: INTEGER
  817. do
  818. cb_map := act
  819. if cb_map /= Void then
  820. operation := 1
  821. else
  822. operation := 0
  823. end
  824. iup_open.set_callback (Current, "MAP_CB", "NONEEDED", operation)
  825. end
  826. set_cb_unmap (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  827. -- Called right before an element is unmapped.
  828. local
  829. operation: INTEGER
  830. do
  831. cb_unmap := act
  832. if cb_unmap /= Void then
  833. operation := 1
  834. else
  835. operation := 0
  836. end
  837. iup_open.set_callback (Current, "UNMAP_CB", "NONEEDED", operation)
  838. end
  839. set_cb_destroy (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  840. -- Called right before an element is destroyed.
  841. local
  842. operation: INTEGER
  843. do
  844. cb_destroy := act
  845. if cb_destroy /= Void then
  846. operation := 1
  847. else
  848. operation := 0
  849. end
  850. iup_open.set_callback (Current, "DESTROY_CB", "NONEEDED", operation)
  851. end
  852. set_cb_get_focus (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  853. -- Action generated when an element is given keyboard focus.
  854. -- This callback is called after the KILLFOCUS_CB of the element
  855. -- that loosed the focus. The {IUP}.get_focus function during the
  856. -- callback returns the element that loosed the focus.
  857. local
  858. operation: INTEGER
  859. do
  860. cb_getfocus := act
  861. if cb_getfocus /= Void then
  862. operation := 1
  863. else
  864. operation := 0
  865. end
  866. iup_open.set_callback (Current, "GETFOCUS_CB", "NONEEDED", operation)
  867. end
  868. set_cb_kill_focus (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  869. -- Action generated when an element loses keyboard focus. This
  870. -- callback is called before the GETFOCUS_CB of the element that
  871. -- gets the focus.
  872. local
  873. operation: INTEGER
  874. do
  875. cb_killfocus := act
  876. if cb_killfocus /= Void then
  877. operation := 1
  878. else
  879. operation := 0
  880. end
  881. iup_open.set_callback (Current, "KILLFOCUS_CB", "NONEEDED", operation)
  882. end
  883. set_cb_enter_window (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  884. -- Action generated when the mouse enters the native element.
  885. local
  886. operation: INTEGER
  887. do
  888. cb_enterwindow := act
  889. if cb_enterwindow /= Void then
  890. operation := 1
  891. else
  892. operation := 0
  893. end
  894. iup_open.set_callback (Current, "ENTERWINDOW_CB", "NONEEDED", operation)
  895. end
  896. set_cb_leave_window (act: FUNCTION[TUPLE[IUP_TREE], STRING])
  897. -- Action generated when the mouse leaves the native element.
  898. local
  899. operation: INTEGER
  900. do
  901. cb_leavewindow := act
  902. if cb_leavewindow /= Void then
  903. operation := 1
  904. else
  905. operation := 0
  906. end
  907. iup_open.set_callback (Current, "LEAVEWINDOW_CB", "NONEEDED", operation)
  908. end
  909. set_cb_k_any (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  910. -- Action generated when a keyboard event occurs.
  911. -- IUP_WIDGET the element that activated the event.
  912. -- INTEGER identifier of typed key. Please refer to the Keyboard
  913. -- Codes table for a list of possible values.
  914. --
  915. -- Returns: If IUP_IGNORE is returned the key is ignored and not
  916. -- processed by the control and not propagated. If returns
  917. -- IUP_CONTINUE, the key will be processed and the event will be
  918. -- propagated to the parent of the element receiving it, this is
  919. -- the default behavior. If returns IUP_DEFAULT the key is processed
  920. -- but it is not propagated. IUP_CLOSE will be processed.
  921. local
  922. operation: INTEGER
  923. do
  924. cb_k_any := act
  925. if cb_k_any /= Void then
  926. operation := 1
  927. else
  928. operation := 0
  929. end
  930. iup_open.set_callback (Current, "K_ANY", "NONEEDED", operation)
  931. end
  932. set_cb_help (act: PROCEDURE[TUPLE[IUP_TREE]])
  933. -- Action generated when the user press F1 at a control. In Motif
  934. -- is also activated by the Help button in some workstations
  935. -- keyboard.
  936. -- Returns: IUP_CLOSE will be processed.
  937. local
  938. operation: INTEGER
  939. do
  940. cb_help := act
  941. if cb_help /= Void then
  942. operation := 1
  943. else
  944. operation := 0
  945. end
  946. iup_open.set_callback (Current, "HELP_CB", "NONEEDED", operation)
  947. end
  948. -- Extra
  949. set_cb_button (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING])
  950. -- Action generated when any mouse button is pressed and when it is
  951. -- released. Both calls occur before the ACTION callback when button 1 is
  952. -- being used.
  953. --
  954. -- IUP_BUTTON: identifies the element that activated the event.
  955. -- button: identifies the activated mouse button:
  956. --
  957. -- 1 - left mouse button (button 1);
  958. -- 2 - middle mouse button (button 2);
  959. -- 3 - right mouse button (button 3).
  960. --
  961. -- pressed: indicates the state of the button:
  962. --
  963. -- 0 - mouse button was released;
  964. -- 1 - mouse button was pressed.
  965. --
  966. -- x, y: position in the canvas where the event has occurred, in pixels.
  967. --
  968. -- status: status of the mouse buttons and some keyboard keys at the
  969. -- moment the event is generated. The following IUP features must be used
  970. -- for verification:
  971. --
  972. -- is_shift(status)
  973. -- is_control(status)
  974. -- is_button_1(status)
  975. -- is_button_2(status)
  976. -- is_button_3(status)
  977. -- is_button_4(status)
  978. -- is_button_5(status)
  979. -- is_double(status)
  980. -- is_alt(status)
  981. -- is_sys(status)
  982. --
  983. -- Returns: IUP_CLOSE will be processed. On some controls if IUP_IGNORE
  984. -- is returned the action is ignored (this is system dependent).
  985. local
  986. operation: INTEGER
  987. do
  988. cb_button := act
  989. if cb_button /= Void then
  990. operation := 1
  991. else
  992. operation := 0
  993. end
  994. iup_open.set_callback (Current, "BUTTON_CB", "NONEEDED", operation)
  995. end
  996. set_cb_motion (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, STRING], STRING])
  997. -- Action generated when the mouse moves.
  998. -- ih: identifier of the element that activated the event.
  999. -- x, y: position in the canvas where the event has occurred, in pixels.
  1000. -- status: status of mouse buttons and certain keyboard keys at the
  1001. -- moment the event was generated. The same macros used for BUTTON_CB can
  1002. -- be used for this status.
  1003. local
  1004. operation: INTEGER
  1005. do
  1006. cb_motion := act
  1007. if cb_motion /= Void then
  1008. operation := 1
  1009. else
  1010. operation := 0
  1011. end
  1012. iup_open.set_callback (Current, "MOTION_CB", "NONEEDED", operation)
  1013. end
  1014. set_cb_drop_files (act: FUNCTION[TUPLE[IUP_TREE, STRING, INTEGER, INTEGER, INTEGER], STRING])
  1015. -- [Windows and GTK Only]: Action generated when one or more files are
  1016. -- dropped in the element.
  1017. -- If defined after the element is mapped then the attribute
  1018. -- DROPFILESTARGET must be set to YES. [Windows and GTK Only]
  1019. local
  1020. operation: INTEGER
  1021. do
  1022. cb_dropfiles := act
  1023. if cb_dropfiles /= Void then
  1024. operation := 1
  1025. else
  1026. operation := 0
  1027. end
  1028. iup_open.set_callback (Current, "DROPFILES_CB", "NONEEDED", operation)
  1029. end
  1030. set_cb_drag_drop (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER], STRING])
  1031. -- Action generated when an internal drag and drop is executed. Only
  1032. -- active if SHOWDRAGDROP=True.
  1033. --
  1034. -- ih: identifier of the element that activated the event.
  1035. -- drag_id: Identifier of the clicked item where the drag start.
  1036. -- drop_id: Identifier of the clicked item where the drop were executed.
  1037. -- -1 indicates a drop in a blank area.
  1038. -- isshift: flag indicating the shift key state.
  1039. -- iscontrol: flag indicating the control key state.
  1040. --
  1041. -- Returns: if returns IUP_CONTINUE, or if the callback is not defined
  1042. -- and SHOWDRAGDROP=True, then the node is moved to the new position. If
  1043. -- Ctrl is pressed then the node is copied instead of moved. If the drop
  1044. -- node is a branch and it is expanded, then the drag node is inserted as
  1045. -- the first child of the node. If the branch is not expanded or the node
  1046. -- is a leaf, then the drag node is inserted as the next brother of the
  1047. -- drop node.
  1048. local
  1049. operation: INTEGER
  1050. do
  1051. cb_dragdrop := act
  1052. if cb_dragdrop /= Void then
  1053. operation := 1
  1054. else
  1055. operation := 0
  1056. end
  1057. iup_open.set_callback (Current, "DRAGDROP_CB", "NONEEDED", operation)
  1058. end
  1059. set_cb_right_click (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  1060. -- Action generated when the right mouse button is pressed over a node.
  1061. --
  1062. -- ih: identifier of the element that activated the event.
  1063. -- id: node identifier.
  1064. local
  1065. operation: INTEGER
  1066. do
  1067. cb_rightclick := act
  1068. if cb_rightclick /= Void then
  1069. operation := 1
  1070. else
  1071. operation := 0
  1072. end
  1073. iup_open.set_callback (Current, "RIGHTCLICK_CB", "NONEEDED", operation)
  1074. end
  1075. set_cb_selection (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING])
  1076. -- Action generated when a node is selected or deselected. This action
  1077. -- occurs when the user clicks with the mouse or uses the keyboard with
  1078. -- the appropriate combination of keys. It may be called more than once
  1079. -- for the same node with the same status.
  1080. --
  1081. -- ih: identifier of the element that activated the event.
  1082. -- id: Node identifier.
  1083. -- status: 1=node selected, 0=node unselected.
  1084. local
  1085. operation: INTEGER
  1086. do
  1087. cb_selection := act
  1088. if cb_selection /= Void then
  1089. operation := 1
  1090. else
  1091. operation := 0
  1092. end
  1093. iup_open.set_callback (Current, "SELECTION_CB", "NONEEDED", operation)
  1094. end
  1095. set_cb_multi_selection (act: FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING])
  1096. -- Action generated after a continuous range of nodes is selected in one
  1097. -- single operation. If not defined the SELECTION_CB with status=1 will
  1098. -- be called for all nodes in the range. The range is always completely
  1099. -- included, independent if some nodes were already marked. That single
  1100. -- operation also guaranties that all other nodes outside the range are
  1101. -- already not selected. Called only if MARKMODE=MULTIPLE.
  1102. --
  1103. -- ih: identifier of the element that activated the event.
  1104. -- ids: Array of node identifiers. This array is kept for backward
  1105. -- compatibility, the range is simply defined by ids[0] to ids[n-1],
  1106. -- where ids[i+1]=ids[i]+1.
  1107. -- n: Number of nodes in the array.
  1108. local
  1109. operation: INTEGER
  1110. do
  1111. cb_multiselection := act
  1112. if cb_multiselection /= Void then
  1113. operation := 1
  1114. else
  1115. operation := 0
  1116. end
  1117. iup_open.set_callback (Current, "MULTISELECTION_CB", "NONEEDED", operation)
  1118. end
  1119. set_cb_multi_unselection (act: FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING])
  1120. local
  1121. operation: INTEGER
  1122. do
  1123. cb_multiunselection := act
  1124. if cb_multiunselection /= Void then
  1125. operation := 1
  1126. else
  1127. operation := 0
  1128. end
  1129. iup_open.set_callback (Current, "MULTIUNSELECTION_CB", "NONEEDED", operation)
  1130. end
  1131. set_cb_branch_open (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  1132. -- Action generated when a branch is expanded. This action occurs when
  1133. -- the user clicks the "+" sign on the left of the branch, or when double
  1134. -- clicks the branch, or hits Enter on a collapsed branch.
  1135. --
  1136. -- ih: identifier of the element that activated the event.
  1137. -- id: node identifier.
  1138. --
  1139. -- Returns: IUP_IGNORE for the branch not to be opened, or IUP_DEFAULT
  1140. -- for the branch to be opened.
  1141. local
  1142. operation: INTEGER
  1143. do
  1144. cb_branchopen := act
  1145. if cb_branchopen /= Void then
  1146. operation := 1
  1147. else
  1148. operation := 0
  1149. end
  1150. iup_open.set_callback (Current, "BRANCHOPEN_CB", "NONEEDED", operation)
  1151. end
  1152. set_cb_branch_close (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  1153. -- Action generated when a branch is collapsed. This action occurs when
  1154. -- the user clicks the "-" sign on the left of the branch, or when double
  1155. -- clicks the branch, or hits Enter on an expanded branch.
  1156. --
  1157. -- ih: identifier of the element that activated the event.
  1158. -- id: node identifier.
  1159. --
  1160. -- Returns: IUP_IGNORE for the branch not to be closed, or IUP_DEFAULT
  1161. -- for the branch to be closed.
  1162. local
  1163. operation: INTEGER
  1164. do
  1165. cb_branchclose := act
  1166. if cb_branchclose /= Void then
  1167. operation := 1
  1168. else
  1169. operation := 0
  1170. end
  1171. iup_open.set_callback (Current, "BRANCHCLOSE_CB", "NONEEDED", operation)
  1172. end
  1173. set_cb_execute_leaf (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  1174. -- Action generated when a leaf is to be executed. This action occurs
  1175. -- when the user double clicks a leaf, or hits Enter on a leaf.
  1176. --
  1177. -- ih: identifier of the element that activated the event.
  1178. -- id: node identifier.
  1179. local
  1180. operation: INTEGER
  1181. do
  1182. cb_executeleaf := act
  1183. if cb_executeleaf /= Void then
  1184. operation := 1
  1185. else
  1186. operation := 0
  1187. end
  1188. iup_open.set_callback (Current, "EXECUTELEAF_CB", "NONEEDED", operation)
  1189. end
  1190. set_cb_show_rename (act: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING])
  1191. -- Action generated when a node is about to be renamed. It occurs when
  1192. -- the user clicks twice the node or press F2. Called only if
  1193. -- SHOWRENAME=True.
  1194. --
  1195. -- ih: identifier of the element that activated the event.
  1196. -- id: node identifier.
  1197. --
  1198. -- Returns: if IUP_IGNORE is returned, the rename is canceled (in GTK the
  1199. -- rename continuous but the edit box is read-only).
  1200. local
  1201. operation: INTEGER
  1202. do
  1203. cb_showrename := act
  1204. if cb_showrename /= Void then
  1205. operation := 1
  1206. else
  1207. operation := 0
  1208. end
  1209. iup_open.set_callback (Current, "SHOWRENAME_CB", "NONEEDED", operation)
  1210. end
  1211. set_cb_rename (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, STRING], STRING])
  1212. -- Action generated after a node was renamed in place. It occurs when the
  1213. -- user press Enter after editing the name, or when the text box looses
  1214. -- it focus. Called only if SHOWRENAME=True.
  1215. --
  1216. -- ih: identifier of the element that activated the event.
  1217. -- id: node identifier.
  1218. -- title: new node title.
  1219. --
  1220. -- Returns: The new title is accepted only if the callback returns
  1221. -- IUP_DEFAULT. If the callback does not exists the new title is always
  1222. -- accepted. If the user pressed Enter and the callback returns
  1223. -- IUP_IGNORE the editing continues. If the text box looses its focus the
  1224. -- editing stops always.
  1225. local
  1226. operation: INTEGER
  1227. do
  1228. cb_rename := act
  1229. if cb_rename /= Void then
  1230. operation := 1
  1231. else
  1232. operation := 0
  1233. end
  1234. iup_open.set_callback (Current, "RENAME_CB", "NONEEDED", operation)
  1235. end
  1236. set_cb_node_removed (act: FUNCTION[TUPLE[IUP_TREE, STRING], STRING])
  1237. -- Action generated when a node is going to be removed. It is only a
  1238. -- notification, the action can not be aborted. No node dependent
  1239. -- attribute can be consulted during the callback. Not called when the
  1240. -- tree is unmapped. It is useful to remove memory allocated for the
  1241. -- userdata.
  1242. --
  1243. -- ih: identifier of the element that activated the event.
  1244. -- userdata/userid: USERDATA attribute in C.
  1245. local
  1246. operation: INTEGER
  1247. do
  1248. cb_noderemoved := act
  1249. if cb_noderemoved /= Void then
  1250. operation := 1
  1251. else
  1252. operation := 0
  1253. end
  1254. iup_open.set_callback (Current, "NODEREMOVED_CB", "NONEEDED", operation)
  1255. end
  1256. set_cb_toggle_value (act: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING])
  1257. -- Action generated when the toggle's state was changed. The callback
  1258. -- also receives the new toggle's state.
  1259. --
  1260. -- ih: identifier of the element that activated the event.
  1261. -- id: node identifier.
  1262. -- state: 1 if the toggle's state was shifted to ON; 0 if it was shifted
  1263. -- to OFF. If SHOW3STATE=YES, −1 if it was shifted to NOTDEF.
  1264. local
  1265. operation: INTEGER
  1266. do
  1267. cb_togglevalue := act
  1268. if cb_togglevalue /= Void then
  1269. operation := 1
  1270. else
  1271. operation := 0
  1272. end
  1273. iup_open.set_callback (Current, "TOGGLEVALUE_CB", "Fnii", operation)
  1274. end
  1275. feature {IUP}
  1276. -- Common callbacks
  1277. execute_map: STRING
  1278. do
  1279. Result := cb_map.item([Current])
  1280. end
  1281. execute_unmap: STRING
  1282. do
  1283. Result := cb_unmap.item([Current])
  1284. end
  1285. execute_destroy: STRING
  1286. do
  1287. Result := cb_destroy.item([Current])
  1288. end
  1289. execute_getfocus: STRING
  1290. do
  1291. Result := cb_getfocus.item([Current])
  1292. end
  1293. execute_killfocus: STRING
  1294. do
  1295. Result := cb_getfocus.item([Current])
  1296. end
  1297. execute_enterwindow: STRING
  1298. do
  1299. Result := cb_enterwindow.item([Current])
  1300. end
  1301. execute_leavewindow: STRING
  1302. do
  1303. Result := cb_leavewindow.item([Current])
  1304. end
  1305. execute_k_any (c: INTEGER): STRING
  1306. do
  1307. Result := cb_k_any.item([Current, c])
  1308. end
  1309. execute_help
  1310. do
  1311. cb_help.call([Current])
  1312. end
  1313. -- Extra
  1314. execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
  1315. do
  1316. Result := cb_button.item([Current, btn, pressed, x, y, status])
  1317. end
  1318. execute_motion (x, y: INTEGER; status: STRING): STRING
  1319. do
  1320. Result := cb_motion.item([Current, x, y, status])
  1321. end
  1322. execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
  1323. do
  1324. Result := cb_dropfiles.item([Current, filename, num, x, y])
  1325. end
  1326. execute_dragdrop (drag_id, drop_id, isshift, iscontrol: INTEGER): STRING
  1327. do
  1328. Result := cb_dragdrop.item([Current, drag_id, drop_id, isshift, iscontrol])
  1329. end
  1330. execute_rightclick (id: INTEGER): STRING
  1331. do
  1332. Result := cb_rightclick.item([Current, id])
  1333. end
  1334. -- Others
  1335. execute_selection (id, status: INTEGER): STRING
  1336. do
  1337. Result := cb_selection.item([Current, id, status])
  1338. end
  1339. execute_multiselection (ids: POINTER; n: INTEGER): STRING
  1340. do
  1341. Result := cb_multiselection.item([Current, ids, n])
  1342. end
  1343. execute_multiunselection (ids: POINTER; n: INTEGER): STRING
  1344. do
  1345. Result := cb_multiunselection.item([Current, ids, n])
  1346. end
  1347. ---------------
  1348. execute_branchopen (id: INTEGER): STRING
  1349. do
  1350. Result := cb_branchopen.item([Current, id])
  1351. end
  1352. execute_branchclose (id: INTEGER): STRING
  1353. do
  1354. Result := cb_branchclose.item([Current, id])
  1355. end
  1356. execute_executeleaf (id: INTEGER): STRING
  1357. do
  1358. Result := cb_executeleaf.item([Current, id])
  1359. end
  1360. -------------------
  1361. execute_showrename (id: INTEGER): STRING
  1362. do
  1363. Result := cb_showrename.item([Current, id])
  1364. end
  1365. execute_rename (id: INTEGER; title: STRING): STRING
  1366. do
  1367. Result := cb_rename.item([Current, id, title])
  1368. end
  1369. -------------------
  1370. execute_noderemoved (userdata: POINTER): STRING
  1371. local
  1372. str: STRING
  1373. do
  1374. if userdata.is_not_null then
  1375. create str.from_external_copy(userdata)
  1376. else
  1377. str := ""
  1378. end
  1379. Result := cb_noderemoved.item([Current, str])
  1380. end
  1381. -------------------
  1382. execute_togglevalue (id, state: INTEGER): STRING
  1383. do
  1384. Result := cb_togglevalue.item([Current, id, state])
  1385. end
  1386. feature {}
  1387. -- For callbacks
  1388. cb_map: FUNCTION[TUPLE[IUP_TREE], STRING]
  1389. cb_unmap: FUNCTION[TUPLE[IUP_TREE], STRING]
  1390. cb_destroy: FUNCTION[TUPLE[IUP_TREE], STRING]
  1391. cb_getfocus: FUNCTION[TUPLE[IUP_TREE], STRING]
  1392. cb_killfocus: FUNCTION[TUPLE[IUP_TREE], STRING]
  1393. cb_enterwindow: FUNCTION[TUPLE[IUP_TREE], STRING]
  1394. cb_leavewindow: FUNCTION[TUPLE[IUP_TREE], STRING]
  1395. cb_k_any: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1396. cb_help: PROCEDURE[TUPLE[IUP_TREE]]
  1397. cb_button: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
  1398. cb_motion: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, STRING], STRING]
  1399. cb_dropfiles: FUNCTION[TUPLE[IUP_TREE, STRING, INTEGER, INTEGER, INTEGER], STRING]
  1400. cb_dragdrop: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER], STRING]
  1401. cb_rightclick: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1402. cb_selection: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING]
  1403. cb_multiselection: FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING]
  1404. cb_multiunselection: FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING]
  1405. cb_branchopen: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1406. cb_branchclose: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1407. cb_executeleaf: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1408. cb_showrename: FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1409. cb_rename: FUNCTION[TUPLE[IUP_TREE, INTEGER, STRING], STRING]
  1410. cb_noderemoved: FUNCTION[TUPLE[IUP_TREE, STRING], STRING]
  1411. cb_togglevalue: FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING]
  1412. -- Internal
  1413. int_tree: POINTER
  1414. external "plug_in"
  1415. alias "{
  1416. location: "${sys}/plugins"
  1417. module_name: "iup"
  1418. feature_name: "IupTree()"
  1419. }"
  1420. end
  1421. -- Validations
  1422. is_valid_state (value: STRING): BOOLEAN
  1423. do
  1424. if value.is_equal("EXPANDED") or
  1425. value.is_equal("COLLAPSED") then
  1426. Result := True
  1427. else
  1428. Result := False
  1429. end
  1430. end
  1431. is_valid_toggle (value: STRING): BOOLEAN
  1432. do
  1433. if value.is_equal("ON") or
  1434. value.is_equal("OFF") or
  1435. value.is_equal("NOTDEF") then
  1436. Result := True
  1437. else
  1438. Result := False
  1439. end
  1440. end
  1441. is_valid_mode (value: STRING): BOOLEAN
  1442. do
  1443. if value.is_equal("SINGLE") or
  1444. value.is_equal("MULTIPLE") then
  1445. Result := True
  1446. else
  1447. Result := False
  1448. end
  1449. end
  1450. end
  1451. -- The MIT License (MIT)
  1452. -- Copyright (c) 2016, 2017, 2018 by German A. Arias
  1453. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  1454. -- of this software and associated documentation files (the "Software"), to deal
  1455. -- in the Software without restriction, including without limitation the rights
  1456. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1457. -- copies of the Software, and to permit persons to whom the Software is
  1458. -- furnished to do so, subject to the following conditions:
  1459. --
  1460. -- The above copyright notice and this permission notice shall be included in
  1461. -- all copies or substantial portions of the Software.
  1462. --
  1463. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1464. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1465. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1466. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1467. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1468. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1469. -- SOFTWARE.