iup_tree.e 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  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.integer_32_item(1), tup.integer_32_item(2), tup.integer_32_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.out)
  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.out)
  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.out)
  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_widget_name 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.out)
  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.out
  542. str.append_string("-")
  543. str.append_string(last.out
  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.out)
  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.out)
  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.out)
  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.out)
  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.out)
  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.make_from_string(col1.out)
  792. str.append_string(":")
  793. str.append_string(col2.out)
  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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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: detachable 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. -- Validations
  1276. is_valid_state (value: STRING): BOOLEAN
  1277. do
  1278. if value.is_equal("EXPANDED") or
  1279. value.is_equal("COLLAPSED") then
  1280. Result := True
  1281. else
  1282. Result := False
  1283. end
  1284. end
  1285. is_valid_toggle (value: STRING): BOOLEAN
  1286. do
  1287. if value.is_equal("ON") or
  1288. value.is_equal("OFF") or
  1289. value.is_equal("NOTDEF") then
  1290. Result := True
  1291. else
  1292. Result := False
  1293. end
  1294. end
  1295. is_valid_mode (value: STRING): BOOLEAN
  1296. do
  1297. if value.is_equal("SINGLE") or
  1298. value.is_equal("MULTIPLE") then
  1299. Result := True
  1300. else
  1301. Result := False
  1302. end
  1303. end
  1304. feature {IUP}
  1305. -- Common callbacks
  1306. execute_map: STRING
  1307. do
  1308. if attached cb_map as int_cb then
  1309. Result := int_cb.item([Current])
  1310. else
  1311. Result := "IUP_DEFAULT"
  1312. end
  1313. end
  1314. execute_unmap: STRING
  1315. do
  1316. if attached cb_unmap as int_cb then
  1317. Result := int_cb.item([Current])
  1318. else
  1319. Result := "IUP_DEFAULT"
  1320. end
  1321. end
  1322. execute_destroy: STRING
  1323. do
  1324. if attached cb_destroy as int_cb then
  1325. Result := int_cb.item([Current])
  1326. else
  1327. Result := "IUP_DEFAULT"
  1328. end
  1329. end
  1330. execute_getfocus: STRING
  1331. do
  1332. if attached cb_getfocus as int_cb then
  1333. Result := int_cb.item([Current])
  1334. else
  1335. Result := "IUP_DEFAULT"
  1336. end
  1337. end
  1338. execute_killfocus: STRING
  1339. do
  1340. if attached cb_killfocus as int_cb then
  1341. Result := int_cb.item([Current])
  1342. else
  1343. Result := "IUP_DEFAULT"
  1344. end
  1345. end
  1346. execute_enterwindow: STRING
  1347. do
  1348. if attached cb_enterwindow as int_cb then
  1349. Result := int_cb.item([Current])
  1350. else
  1351. Result := "IUP_DEFAULT"
  1352. end
  1353. end
  1354. execute_leavewindow: STRING
  1355. do
  1356. if attached cb_leavewindow as int_cb then
  1357. Result := int_cb.item([Current])
  1358. else
  1359. Result := "IUP_DEFAULT"
  1360. end
  1361. end
  1362. execute_k_any (c: INTEGER): STRING
  1363. do
  1364. if attached cb_k_any as int_cb then
  1365. Result := int_cb.item([Current, c])
  1366. else
  1367. Result := "IUP_DEFAULT"
  1368. end
  1369. end
  1370. execute_help
  1371. do
  1372. if attached cb_help as int_cb then
  1373. int_cb.call([Current])
  1374. end
  1375. end
  1376. -- Extra
  1377. execute_button (btn, pressed, x, y: INTEGER; status: STRING): STRING
  1378. do
  1379. if attached cb_button as int_cb then
  1380. Result := int_cb.item([Current, btn, pressed, x, y, status])
  1381. else
  1382. Result := "IUP_DEFAULT"
  1383. end
  1384. end
  1385. execute_motion (x, y: INTEGER; status: STRING): STRING
  1386. do
  1387. if attached cb_motion as int_cb then
  1388. Result := int_cb.item([Current, x, y, status])
  1389. else
  1390. Result := "IUP_DEFAULT"
  1391. end
  1392. end
  1393. execute_dropfiles (filename: STRING; num: INTEGER; x: INTEGER; y: INTEGER): STRING
  1394. do
  1395. if attached cb_dropfiles as int_cb then
  1396. Result := int_cb.item([Current, filename, num, x, y])
  1397. else
  1398. Result := "IUP_DEFAULT"
  1399. end
  1400. end
  1401. execute_dragdrop (drag_id, drop_id, isshift, iscontrol: INTEGER): STRING
  1402. do
  1403. if attached cb_dragdrop as int_cb then
  1404. Result := int_cb.item([Current, drag_id, drop_id, isshift, iscontrol])
  1405. else
  1406. Result := "IUP_DEFAULT"
  1407. end
  1408. end
  1409. execute_rightclick (id: INTEGER): STRING
  1410. do
  1411. if attached cb_rightclick as int_cb then
  1412. Result := int_cb.item([Current, id])
  1413. else
  1414. Result := "IUP_DEFAULT"
  1415. end
  1416. end
  1417. -- Others
  1418. execute_selection (id, status: INTEGER): STRING
  1419. do
  1420. if attached cb_selection as int_cb then
  1421. Result := int_cb.item([Current, id, status])
  1422. else
  1423. Result := "IUP_DEFAULT"
  1424. end
  1425. end
  1426. execute_multiselection (ids: POINTER; n: INTEGER): STRING
  1427. do
  1428. if attached cb_multiselection as int_cb then
  1429. Result := int_cb.item([Current, ids, n])
  1430. else
  1431. Result := "IUP_DEFAULT"
  1432. end
  1433. end
  1434. execute_multiunselection (ids: POINTER; n: INTEGER): STRING
  1435. do
  1436. if attached cb_multiunselection as int_cb then
  1437. Result := int_cb.item([Current, ids, n])
  1438. else
  1439. Result := "IUP_DEFAULT"
  1440. end
  1441. end
  1442. ---------------
  1443. execute_branchopen (id: INTEGER): STRING
  1444. do
  1445. if attached cb_branchopen as int_cb then
  1446. Result := int_cb.item([Current, id])
  1447. else
  1448. Result := "IUP_DEFAULT"
  1449. end
  1450. end
  1451. execute_branchclose (id: INTEGER): STRING
  1452. do
  1453. if attached cb_branchclose as int_cb then
  1454. Result := int_cb.item([Current, id])
  1455. else
  1456. Result := "IUP_DEFAULT"
  1457. end
  1458. end
  1459. execute_executeleaf (id: INTEGER): STRING
  1460. do
  1461. if attached cb_executeleaf as int_cb then
  1462. Result := int_cb.item([Current, id])
  1463. else
  1464. Result := "IUP_DEFAULT"
  1465. end
  1466. end
  1467. -------------------
  1468. execute_showrename (id: INTEGER): STRING
  1469. do
  1470. if attached cb_showrename as int_cb then
  1471. Result := int_cb.item([Current, id])
  1472. else
  1473. Result := "IUP_DEFAULT"
  1474. end
  1475. end
  1476. execute_rename (id: INTEGER; title: STRING): STRING
  1477. do
  1478. if attached cb_rename as int_cb then
  1479. Result := int_cb.item([Current, id, title])
  1480. else
  1481. Result := "IUP_DEFAULT"
  1482. end
  1483. end
  1484. -------------------
  1485. execute_noderemoved (userdata: POINTER): STRING
  1486. local
  1487. str: STRING
  1488. do
  1489. if userdata /= default_pointer then
  1490. create str.make_from_c(userdata)
  1491. else
  1492. str := ""
  1493. end
  1494. if attached cb_noderemoved as int_cb then
  1495. Result := int_cb.item([Current, str])
  1496. else
  1497. Result := "IUP_DEFAULT"
  1498. end
  1499. end
  1500. -------------------
  1501. execute_togglevalue (id, state: INTEGER): STRING
  1502. do
  1503. if attached cb_togglevalue as int_cb then
  1504. Result := int_cb.item([Current, id, state])
  1505. else
  1506. Result := "IUP_DEFAULT"
  1507. end
  1508. end
  1509. feature {NONE}
  1510. -- For callbacks
  1511. cb_map: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1512. cb_unmap: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1513. cb_destroy: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1514. cb_getfocus: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1515. cb_killfocus: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1516. cb_enterwindow: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1517. cb_leavewindow: detachable FUNCTION[TUPLE[IUP_TREE], STRING]
  1518. cb_k_any: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1519. cb_help: detachable PROCEDURE[TUPLE[IUP_TREE]]
  1520. cb_button: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
  1521. cb_motion: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, STRING], STRING]
  1522. cb_dropfiles: detachable FUNCTION[TUPLE[IUP_TREE, STRING, INTEGER, INTEGER, INTEGER], STRING]
  1523. cb_dragdrop: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER, INTEGER, INTEGER], STRING]
  1524. cb_rightclick: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1525. cb_selection: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING]
  1526. cb_multiselection: detachable FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING]
  1527. cb_multiunselection: detachable FUNCTION[TUPLE[IUP_TREE, POINTER, INTEGER], STRING]
  1528. cb_branchopen: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1529. cb_branchclose: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1530. cb_executeleaf: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1531. cb_showrename: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER], STRING]
  1532. cb_rename: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, STRING], STRING]
  1533. cb_noderemoved: detachable FUNCTION[TUPLE[IUP_TREE, STRING], STRING]
  1534. cb_togglevalue: detachable FUNCTION[TUPLE[IUP_TREE, INTEGER, INTEGER], STRING]
  1535. -- Internal
  1536. int_tree: POINTER
  1537. external
  1538. "C inline use %"eiffel-iup.h%""
  1539. alias
  1540. "return IupTree();"
  1541. end
  1542. end
  1543. -- The MIT License (MIT)
  1544. -- Copyright (c) 2016, 2017, 2018, 2019, 2020 by German A. Arias
  1545. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  1546. -- of this software and associated documentation files (the "Software"), to deal
  1547. -- in the Software without restriction, including without limitation the rights
  1548. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1549. -- copies of the Software, and to permit persons to whom the Software is
  1550. -- furnished to do so, subject to the following conditions:
  1551. --
  1552. -- The above copyright notice and this permission notice shall be included in
  1553. -- all copies or substantial portions of the Software.
  1554. --
  1555. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1556. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1557. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1558. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1559. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1560. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1561. -- SOFTWARE.