iup_matrix.e 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632
  1. class IUP_MATRIX
  2. -- Creates a matrix of alphanumeric fields. Therefore, all values of the matrix
  3. -- fields are strings. The matrix is not a grid container like many systems
  4. -- have. It inherits from IUP_CANVAS.
  5. --
  6. -- This is an additional control that depends on the CD library. You should
  7. -- call "load_controls" to use it.
  8. --
  9. -- It has two modes of operation: normal and callback mode. In normal mode,
  10. -- string values are stored in attributes for each cell. In callback mode these
  11. -- attributes are ignored and the cells are filled with strings returned by the
  12. -- "VALUE_CB" callback. So the existence of this callback defines the mode the
  13. -- matrix will operate.
  14. --
  15. -- Notice that it is possible to use the IUP_FLAT_SCROLL_BOX to overcome the
  16. -- internal scrollbars of another control like IUP_MATRIX by making all cells
  17. -- visible, but this will force all cells to be drawn all the time even when
  18. -- not visible at the scroll box, which is much slower than the internal
  19. -- IUP_MATRIX optimization. So, by default, this is not used.
  20. inherit
  21. IUP_CONTROLS
  22. rename
  23. canvas as matrix
  24. redefine
  25. matrix,
  26. set_cursor,
  27. set_border,
  28. set_scroll_bar,
  29. execute_action_fniiiis,
  30. execute_click_fniis,
  31. execute_colresize,
  32. execute_release,
  33. execute_resizematrix,
  34. execute_togglevalue_fniii,
  35. execute_valuechanged,
  36. execute_mousemove,
  37. execute_enteritem,
  38. execute_leaveitem,
  39. execute_scrolltop,
  40. execute_bgcolor,
  41. execute_fgcolor,
  42. execute_font,
  43. execute_type,
  44. execute_draw,
  45. execute_dropcheck,
  46. execute_translatevalue,
  47. execute_drop,
  48. execute_menudrop,
  49. execute_dropselect,
  50. execute_edition,
  51. execute_value,
  52. execute_value_edit,
  53. execute_mark,
  54. execute_markedit
  55. end
  56. IUP_WIDGET_FGCOLOR
  57. IUP_WIDGET_FLAT_SCROLL_BOX
  58. IUP_WIDGET_TEXT_POS
  59. create {ANY}
  60. matrix
  61. feature {ANY}
  62. matrix
  63. local
  64. p, a_matrix: POINTER
  65. do
  66. a_matrix := int_matrix (p)
  67. set_widget(a_matrix)
  68. create_mask_dictionary
  69. end
  70. -- General Attributes
  71. set_cursor (name: STRING)
  72. -- Default cursor used by the matrix. The default cursor is a symbol that
  73. -- looks like a cross. If you need to refer to this default cursor, use
  74. -- the name "IupMatrixCrossCursor".
  75. do
  76. Precursor (name)
  77. end
  78. set_drop_image (name: STRING)
  79. -- drop image name. Use set_attribute_handle to associate an image to a
  80. -- name. See also IUP_IMAGE. By default an internal image will be used.
  81. do
  82. iup_open.set_attribute(Current, "DROPIMAGE", name)
  83. end
  84. set_focus_cell (line, column: INTEGER)
  85. -- Defines the current cell (line>0 and column>0, a title cell can NOT be
  86. -- the current cell). Default: "1:1".
  87. require
  88. non_negative: line >= 0
  89. column >= 0
  90. local
  91. str: STRING
  92. do
  93. str := line.to_string
  94. str.append_string(":")
  95. str.append_string(column.to_string)
  96. iup_open.set_attribute(Current, "FOCUSCELL", str)
  97. end
  98. get_focus_cell: TUPLE[INTEGER, INTEGER]
  99. -- Returns the [line, column] of the focus cell.
  100. local
  101. str: STRING
  102. do
  103. str := iup_open.get_attribute(Current, "FOCUSCELL")
  104. Result := components_of (str, ':')
  105. end
  106. set_flat (state: BOOLEAN)
  107. -- Removes the 3D appearance from the matrix.
  108. do
  109. iup_open.set_attribute(Current, "FLAT", boolean_to_yesno(state))
  110. end
  111. set_hide_focus (state: BOOLEAN)
  112. -- Do not show the focus mark when drawing the matrix. Default is False.
  113. do
  114. iup_open.set_attribute(Current, "HIDEFOCUS", boolean_to_yesno(state))
  115. end
  116. set_hidden_text_marks (state: BOOLEAN)
  117. -- When text is greater than cell space, it is normally cropped, but when
  118. -- set to "True" a "..." mark will be added at the crop point to indicate
  119. -- that there is more text not visible. Default: "False".
  120. do
  121. iup_open.set_attribute(Current, "HIDDENTEXTMARKS", boolean_to_yesno(state))
  122. end
  123. set_highlight_color (red, green, blue: INTEGER)
  124. -- (non inheritable): the overlay color for the selected cells.
  125. -- Default: TXTHLCOLOR global attribute. The color is composited using
  126. -- "set_highlight_color_alpha" attribute.
  127. do
  128. iup_open.set_attribute(Current, "HLCOLOR", rgb_to_string(red, green, blue))
  129. end
  130. set_highlight_color_alpha (alpha: INTEGER)
  131. -- Alpha value to be used for selected cell (default is 128).
  132. require
  133. alpha >= 0
  134. alpha <= 255
  135. do
  136. iup_open.set_attribute(Current, "HLCOLORALPHA", alpha.to_string)
  137. end
  138. set_origin (line, column: INTEGER)
  139. -- Scroll the visible area to the given cell.
  140. require
  141. line > 0
  142. column > 0
  143. local
  144. str: STRING
  145. do
  146. str := line.to_string
  147. str.append_string(":")
  148. str.append_string(column.to_string)
  149. iup_open.set_attribute(Current, "ORIGIN", str)
  150. end
  151. get_origin: TUPLE[INTEGER, INTEGER]
  152. -- Returns the cell at the upper left corner.
  153. local
  154. str: STRING
  155. do
  156. str := iup_open.get_attribute(Current, "ORIGIN")
  157. Result := components_of (str, ':')
  158. end
  159. set_line (line: INTEGER)
  160. -- Scroll to a specific line.
  161. require
  162. line > 0
  163. local
  164. str: STRING
  165. do
  166. str := line.to_string
  167. str.append_string(":")
  168. str.append_string("*")
  169. iup_open.set_attribute(Current, "ORIGIN", str)
  170. end
  171. set_column (column: INTEGER)
  172. -- Scroll to a specific column.
  173. require
  174. column > 0
  175. local
  176. str: STRING
  177. do
  178. str := "*:"
  179. str.append_string(column.to_string)
  180. iup_open.set_attribute(Current, "ORIGIN", str)
  181. end
  182. set_origin_offset (x, y: INTEGER)
  183. -- Complements the ORIGIN attribute by specifying the drag offset of the
  184. -- top left cell. When changing this attribute must change also ORIGIN
  185. -- right after.
  186. require
  187. non_negative: x >= 0
  188. y >= 0
  189. local
  190. str: STRING
  191. do
  192. str := x.to_string
  193. str.append_string(":")
  194. str.append_string(y.to_string)
  195. iup_open.set_attribute(Current, "ORIGINOFFSET", str)
  196. end
  197. set_read_only (state: BOOLEAN)
  198. -- Disables the editing of all cells. The callback "edition"
  199. -- and "value_edit" will not be called anymore. The features to change
  200. -- the cell value still work.
  201. do
  202. iup_open.set_attribute(Current, "READONLY", boolean_to_yesno(state))
  203. end
  204. set_show_fill_value (state: BOOLEAN)
  205. -- Enable the display of the numeric percentage in the cell when type is
  206. -- "FILL". Default: False.
  207. do
  208. iup_open.set_attribute(Current, "SHOWFILLVALUE", boolean_to_yesno(state))
  209. end
  210. set_toggle_centered (state: BOOLEAN)
  211. -- Center the toggle. No text will be drawn.
  212. do
  213. iup_open.set_attribute(Current, "TOGGLECENTERED", boolean_to_yesno(state))
  214. end
  215. set_toggle_image_on (name: STRING)
  216. -- Toggle image name when state is ON. See also IUP_IMAGE. By default an
  217. -- internal image will be used.
  218. do
  219. iup_open.set_attribute(Current, "TOGGLEIMAGEON", name)
  220. end
  221. set_toggle_image_off (name: STRING)
  222. -- Toggle image name when state is OFF. See also IUP_IMAGE. By default an
  223. -- internal image will be used.
  224. do
  225. iup_open.set_attribute(Current, "TOGGLEIMAGEOFF", name)
  226. end
  227. set_type_color_inactive (state: BOOLEAN)
  228. -- When inactive the color of the cell of type "COLOR" will be
  229. -- attenuated as everything else. Default: True.
  230. do
  231. iup_open.set_attribute(Current, "TYPECOLORINACTIVE", boolean_to_yesno(state))
  232. end
  233. -- Cell Attributes (no redraw). These attributes are only updated in the
  234. -- display when you redraw.
  235. set_corner_title (title: STRING)
  236. -- Set title of the area between the line and column titles.
  237. do
  238. iup_open.set_attribute_id2(Current, "", 0, 0, title)
  239. end
  240. get_corner_title: STRING
  241. do
  242. Result := iup_open.get_attribute_id2(Current, "", 0, 0)
  243. end
  244. set_line_title (line: INTEGER; title: STRING)
  245. -- Set title of line.
  246. do
  247. iup_open.set_attribute_id2(Current, "", line, 0, title)
  248. end
  249. get_line_title (line: INTEGER): STRING
  250. do
  251. Result := iup_open.get_attribute_id2(Current, "", line, 0)
  252. end
  253. set_column_title (column: INTEGER; title: STRING)
  254. -- Set title of column.
  255. do
  256. iup_open.set_attribute_id2(Current, "", 0, column, title)
  257. end
  258. get_column_title (column: INTEGER): STRING
  259. do
  260. Result := iup_open.get_attribute_id2(Current, "", 0, column)
  261. end
  262. set_text_at_cell (text: STRING; line, column: INTEGER)
  263. -- Set text of the cell located in line and column.
  264. do
  265. iup_open.set_attribute_id2(Current, "", line, column, text)
  266. end
  267. get_text_at_cell (line, column: INTEGER): STRING
  268. do
  269. Result := iup_open.get_attribute_id2(Current, "", line, column)
  270. end
  271. -- The following features are valid only in normal mode.
  272. set_alignment_at (line_align, col_align: STRING; line, column: INTEGER)
  273. -- Alignment of the cell value in line and column. Where line_align can
  274. -- be "ATOP", "ACENTER" or "ABOTTOM", and col_align can be "ALEFT",
  275. -- "ACENTER" or "ARIGHT". Default will use the column alignment
  276. -- and the line alignment.
  277. require
  278. is_valid_lin_align (line_align)
  279. is_valid_col_align (col_align)
  280. line >= 0
  281. column >= 0
  282. local
  283. str: STRING
  284. do
  285. create str.copy(line_align)
  286. str.append_string(":")
  287. str.append_string(col_align)
  288. iup_open.set_attribute_id2(Current, "ALIGN", line, column, str)
  289. end
  290. get_alignment_at (line, column: INTEGER): TUPLE[STRING, STRING]
  291. -- Return the alignment at the cell in format [line_align, col_align]
  292. local
  293. str: STRING
  294. do
  295. str := iup_open.get_attribute_id2(Current, "ALIGN", line, column)
  296. Result := components_of_alignment (str)
  297. end
  298. set_type_cell_at (type: STRING; line, column: INTEGER)
  299. -- Can be "TEXT", "COLOR", "FILL", or "IMAGE". When type is "COLOR" the
  300. -- cell value is interpreted as a color and a rectangle with the color is
  301. -- drawn inside the cell instead of the text (the foreground color of the
  302. -- cell is ignored). When type is "FILL" the cell value is interpreted as
  303. -- percentage and a rectangle showing the percentage in the foreground
  304. -- color is drawn. When type is "IMAGE" the cell value is interpreted as
  305. -- an image name, and if an image exist with that name is drawn (the name
  306. -- can NOT be of a Windows resource or GTK stock image). Only "TEXT" and
  307. -- "IMAGE" are affected by alignment attributes. Default: "TEXT".
  308. require
  309. is_valid_type_cell (type)
  310. line > 0
  311. column > 0
  312. do
  313. iup_open.set_attribute_id2(Current, "TYPE", line, column, type)
  314. end
  315. get_type_cell_at (line, column: INTEGER): STRING
  316. do
  317. Result := iup_open.get_attribute_id2(Current, "TYPE", line, column)
  318. end
  319. set_type_column (type: STRING; column: INTEGER)
  320. require
  321. is_valid_type_cell (type)
  322. column > 0
  323. do
  324. iup_open.set_attribute_id2(Current, "TYPE", -10, column, type)
  325. end
  326. get_type_column (column: INTEGER): STRING
  327. do
  328. Result := iup_open.get_attribute_id2(Current, "TYPE", -10, column)
  329. end
  330. set_type_line (type: STRING; line: INTEGER)
  331. require
  332. is_valid_type_cell (type)
  333. line > 0
  334. do
  335. iup_open.set_attribute_id2(Current, "TYPE", line, -10, type)
  336. end
  337. get_type_line (line: INTEGER): STRING
  338. do
  339. Result := iup_open.get_attribute_id2(Current, "TYPE", line, -10)
  340. end
  341. set_background_color_at (red, green, blue, line, column: INTEGER)
  342. -- When more than one attribute are defined, the background color will be
  343. -- selected following this priority: cell background color,
  344. -- line background color, column background color, and last
  345. -- background color.
  346. --
  347. -- Default background color is the global attribute TXTBGCOLOR for cells
  348. -- and the parent's background for titles.
  349. -- Since the matrix control can be larger than the matrix itself, the
  350. -- empty area will always be filled with the parent's
  351. -- background color.
  352. require
  353. line >= 0
  354. column >= 0
  355. do
  356. iup_open.set_attribute_id2(Current, "BGCOLOR", line, column, rgb_to_string(red, green, blue))
  357. end
  358. get_background_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  359. require
  360. line >= 0
  361. column >= 0
  362. local
  363. str: STRING
  364. do
  365. str := iup_open.get_attribute_id2(Current, "BGCOLOR", line, column)
  366. Result := string_to_rgb(str)
  367. end
  368. set_background_color_at_column (red, green, blue, column: INTEGER)
  369. require
  370. column >= 0
  371. do
  372. iup_open.set_attribute_id2(Current, "BGCOLOR", -10, column, rgb_to_string(red, green, blue))
  373. end
  374. get_background_color_at_column (column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  375. require
  376. column >= 0
  377. local
  378. str: STRING
  379. do
  380. str := iup_open.get_attribute_id2(Current, "BGCOLOR", -10, column)
  381. Result := string_to_rgb(str)
  382. end
  383. set_background_color_at_line (red, green, blue, line: INTEGER)
  384. require
  385. line >= 0
  386. do
  387. iup_open.set_attribute_id2(Current, "BGCOLOR", line, -10, rgb_to_string(red, green, blue))
  388. end
  389. get_background_color_at_line (line: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  390. require
  391. line >= 0
  392. local
  393. str: STRING
  394. do
  395. str := iup_open.get_attribute_id2(Current, "BGCOLOR", line, -10)
  396. Result := string_to_rgb(str)
  397. end
  398. set_foreground_color_at (red, green, blue, line, column: INTEGER)
  399. -- When more than one attribute are defined, the foreground color will be
  400. -- selected following this priority: cell foreground color,
  401. -- line foreground color, column foreground color, and last
  402. -- foreground color.
  403. --
  404. -- Default foreground color is the global attribute TXTFGCOLOR for cells
  405. -- and the parent's foreground for titles.
  406. -- Since the matrix control can be larger than the matrix itself, the
  407. -- empty area will always be filled with the parent's
  408. -- foreground color.
  409. require
  410. line >= 0
  411. column >= 0
  412. do
  413. iup_open.set_attribute_id2(Current, "FGCOLOR", line, column, rgb_to_string(red, green, blue))
  414. end
  415. get_foreground_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  416. require
  417. line >= 0
  418. column >= 0
  419. local
  420. str: STRING
  421. do
  422. str := iup_open.get_attribute_id2(Current, "FGCOLOR", line, column)
  423. Result := string_to_rgb(str)
  424. end
  425. set_foreground_color_at_column (red, green, blue, column: INTEGER)
  426. require
  427. column >= 0
  428. do
  429. iup_open.set_attribute_id2(Current, "FGCOLOR", -10, column, rgb_to_string(red, green, blue))
  430. end
  431. get_foreground_color_at_column (column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  432. require
  433. column >= 0
  434. local
  435. str: STRING
  436. do
  437. str := iup_open.get_attribute_id2(Current, "FGCOLOR", -10, column)
  438. Result := string_to_rgb(str)
  439. end
  440. set_foreground_color_at_line (red, green, blue, line: INTEGER)
  441. require
  442. line >= 0
  443. do
  444. iup_open.set_attribute_id2(Current, "FGCOLOR", line, -10, rgb_to_string(red, green, blue))
  445. end
  446. get_foreground_color_at_line (line: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  447. require
  448. line >= 0
  449. local
  450. str: STRING
  451. do
  452. str := iup_open.get_attribute_id2(Current, "FGCOLOR", line, -10)
  453. Result := string_to_rgb(str)
  454. end
  455. set_font_at (font: STRING; line, column: INTEGER)
  456. -- This attribute must be set before the control is showed. It affects
  457. -- the calculation of the size of all the matrix cells. The cell size is
  458. -- always calculated from the base font attribute.
  459. require
  460. non_negative: line >= 0
  461. column >= 0
  462. do
  463. iup_open.set_attribute_id2(Current, "FONT", line, column, font)
  464. end
  465. set_font_at_column (font: STRING; column: INTEGER)
  466. require
  467. non_negative: column >= 0
  468. do
  469. iup_open.set_attribute_id2(Current, "FONT", -10, column, font)
  470. end
  471. set_font_at_line (font: STRING; line: INTEGER)
  472. require
  473. non_negative: line >= 0
  474. do
  475. iup_open.set_attribute_id2(Current, "FONT", line, -10, font)
  476. end
  477. set_frame_color (red, green, blue: INTEGER)
  478. -- Sets the color to be used in the frame lines. (inheritable)
  479. do
  480. iup_open.set_attribute(Current, "FRAMECOLOR", rgb_to_string(red, green, blue))
  481. end
  482. set_vertical_frame_color_at (red, green, blue, line, column: INTEGER)
  483. -- Color of the vertical right frame line of the cell. When not defined
  484. -- the verticel frame color is used. For a title column cell (column=0)
  485. -- defines right and left frames. If value is "BGCOLOR" the frame line is
  486. -- not drawn.
  487. require
  488. line >= 0
  489. column >= 0
  490. do
  491. iup_open.set_attribute_id2(Current, "FRAMEVERTCOLOR", line, column,
  492. rgb_to_string(red, green, blue))
  493. end
  494. set_vertical_frame_color_at_column (red, green, blue, column: INTEGER)
  495. -- Same as "set_vertical_frame_color_at" but for all the cells of the
  496. -- column.
  497. require
  498. column >= 0
  499. do
  500. iup_open.set_attribute_id2(Current, "FRAMEVERTCOLOR", -10, column,
  501. rgb_to_string(red, green, blue))
  502. end
  503. set_frame_title_vertical_color_at_line (red, green, blue, line: INTEGER)
  504. -- Color of the vertical left frame line of the title cell. When not
  505. -- defined the FRAMEVERTCOLORL:0 is used.
  506. require
  507. line >= 0
  508. do
  509. iup_open.set_attribute_id2(Current, "FRAMETITLEVERTCOLOR", line, 0,
  510. rgb_to_string(red, green, blue))
  511. end
  512. set_frame_title_vertical_color (red, green, blue: INTEGER)
  513. -- Color of the vertical left frame line for all the title cells. When
  514. -- not defined the FRAMEVERTCOLORL:0 is used.
  515. do
  516. iup_open.set_attribute_id2(Current, "FRAMETITLEVERTCOLOR", -10, 0,
  517. rgb_to_string(red, green, blue))
  518. end
  519. set_horizontal_frame_color_at (red, green, blue, line, column: INTEGER)
  520. -- Color of the horizontal bottom frame line of the cell. When not defined
  521. -- the verticel frame color is used. For a title line cell (line=0)
  522. -- defines bottom and top frames. If value is "BGCOLOR" the frame line is
  523. -- not drawn.
  524. require
  525. line >= 0
  526. column >= 0
  527. do
  528. iup_open.set_attribute_id2(Current, "FRAMEHORIZCOLOR", line, column,
  529. rgb_to_string(red, green, blue))
  530. end
  531. set_horizontal_frame_color_at_line (red, green, blue, line: INTEGER)
  532. -- Same as "set_horizontal_frame_color_at" but for all the cells of the
  533. -- line.
  534. require
  535. line >= 0
  536. do
  537. iup_open.set_attribute_id2(Current, "FRAMEHORIZCOLOR", line, -10,
  538. rgb_to_string(red, green, blue))
  539. end
  540. set_frame_title_horizontal_color_at_column (red, green, blue, column: INTEGER)
  541. -- Color of the horizontal top frame line of the title cell. When not
  542. -- defined the FRAMEHORIZCOLOR0:C is used.
  543. require
  544. column >= 0
  545. do
  546. iup_open.set_attribute_id2(Current, "FRAMETITLEHORIZCOLOR", 0, column,
  547. rgb_to_string(red, green, blue))
  548. end
  549. set_frame_title_horizontal_color (red, green, blue: INTEGER)
  550. -- Color of the horizontal top frame line of all title cells. When not
  551. -- defined the FRAMEHORIZCOLOR0:C is used.
  552. do
  553. iup_open.set_attribute_id2(Current, "FRAMETITLEHORIZCOLOR", 0, -10,
  554. rgb_to_string(red, green, blue))
  555. end
  556. set_frame_title_highlight (state: BOOLEAN)
  557. -- By default the title cells will have a bright line at left and top to
  558. -- configure a raise appearance. Default: True.
  559. do
  560. iup_open.set_attribute(Current, "FRAMETITLEHIGHLIGHT", boolean_to_yesno(state))
  561. end
  562. set_frame_border (state: BOOLEAN)
  563. -- Show a fixed border (non scrollable) of 1 pixel around the matrix
  564. -- visible area using FRAMECOLOR. It is drawn after the matrix cells are
  565. -- drawn. Default: False.
  566. do
  567. iup_open.set_attribute(Current, "FRAMEBORDER", boolean_to_yesno(state))
  568. end
  569. set_resize_matrix_color (red, green, blue: INTEGER)
  570. -- Color used by the column resize feedback. Default: "102 102 102".
  571. do
  572. iup_open.set_attribute(Current, "RESIZEMATRIXCOLOR", rgb_to_string(red, green, blue))
  573. end
  574. set_toggle_value_at (value: STRING; line, column: INTEGER)
  575. -- Value of the toggle inside the cell. The toggle is shown only if the
  576. -- DROPCHECK_CB returns IUP_CONTINUE for the cell. When the toggle is
  577. -- interactively change the TOGGLEVALUE_CB callback is called.
  578. require
  579. non_negative: line >= 0
  580. column >= 0
  581. do
  582. iup_open.set_attribute_id2(Current, "TOGGLEVALUE", line, column, value)
  583. end
  584. get_toggle_value_at (line, column: INTEGER): STRING
  585. require
  586. non_negative: line >= 0
  587. column >= 0
  588. do
  589. Result := iup_open.get_attribute_id2 (Current, "TOGGLEVALUE", line, column)
  590. end
  591. set_value (value: STRING)
  592. -- Allows setting the value of the current cell. Is the same as obtaining
  593. -- the current cell line and column with "get_focus_cell", and then using
  594. -- them with "get_text_at_cell" to get text in the cell. But when updated
  595. -- or retrieved during cell editing, the edit control will be updated or
  596. -- consulted instead of the matrix cell. When retrieved inside the
  597. -- EDITION_CB callback when mode is 0, then the return value is the new
  598. -- value that will be updated in the cell.
  599. do
  600. iup_open.set_attribute(Current, "VALUE", value)
  601. end
  602. get_value: STRING
  603. -- When retrieved during cell editing, the edit control will be
  604. -- consulted instead of the matrix cell. When retrieved inside the
  605. -- EDITION_CB callback when mode is 0, then the return value is the new
  606. -- value that will be updated in the cell.
  607. do
  608. Result := iup_open.get_attribute(Current, "VALUE")
  609. end
  610. -- Read only (Cell Attributes)
  611. get_cell_at (line, column: INTEGER): STRING
  612. -- Returns the displayed cell value. Returns Void if the cell does not
  613. -- exists, or it is not visible, or the element is not mapped.
  614. require
  615. non_negative: line >= 0
  616. column >= 0
  617. do
  618. Result := iup_open.get_attribute_id2(Current, "CELL", line, column)
  619. end
  620. get_cell_background_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  621. -- Returns the actual cell background color. Returns Void if the cell
  622. -- does not exists, or it is not visible, or the element is not mapped.
  623. require
  624. non_negative: line >= 0
  625. column >= 0
  626. local
  627. str: STRING
  628. do
  629. str := iup_open.get_attribute_id2(Current, "CELLBGCOLOR", line, column)
  630. Result := string_to_rgb(str)
  631. end
  632. get_cell_foreground_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  633. -- Returns the actual cell foreground color. Returns Void if the cell
  634. -- does not exists, or it is not visible, or the element is not mapped.
  635. require
  636. non_negative: line >= 0
  637. column >= 0
  638. local
  639. str: STRING
  640. do
  641. str := iup_open.get_attribute_id2(Current, "CELLFGCOLOR", line, column)
  642. Result := string_to_rgb(str)
  643. end
  644. get_cell_font_at (line, column: INTEGER): STRING
  645. -- Returns the actual cell font. Returns NULL if the cell does not
  646. -- exists, or it is not visible, or the element is not mapped.
  647. require
  648. non_negative: line >= 0
  649. column >= 0
  650. do
  651. Result := iup_open.get_attribute_id2(Current, "CELLFONT", line, column)
  652. end
  653. get_cell_type_at (line, column: INTEGER): STRING
  654. -- Returns the actual cell type. Returns NULL if the cell does not
  655. -- exists, or it is not visible, or the element is not mapped.
  656. require
  657. non_negative: line >= 0
  658. column >= 0
  659. do
  660. Result := iup_open.get_attribute_id2(Current, "CELLTYPE", line, column)
  661. end
  662. get_cell_frame_horizontal_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  663. -- Returns the actual cell frame horizontal color. Returns NULL if the
  664. -- cell does not exists, or it is not visible, the element is not mapped,
  665. -- or the color is transparent.
  666. require
  667. non_negative: line >= 0
  668. column >= 0
  669. local
  670. str: STRING
  671. do
  672. str := iup_open.get_attribute_id2(Current, "CELLFRAMEHORIZCOLOR", line, column)
  673. Result := string_to_rgb(str)
  674. end
  675. get_cell_frame_vertical_color_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER, INTEGER]
  676. -- Returns the actual cell frame vertical color. Returns NULL if the
  677. -- cell does not exists, or it is not visible, the element is not mapped,
  678. -- or the color is transparent.
  679. require
  680. non_negative: line >= 0
  681. column >= 0
  682. local
  683. str: STRING
  684. do
  685. str := iup_open.get_attribute_id2(Current, "CELLFRAMEVERTCOLOR", line, column)
  686. Result := string_to_rgb(str)
  687. end
  688. get_cell_alignment_at (line, column: INTEGER): STRING
  689. -- Returns the actual cell text aligment, including lin and col
  690. -- variations. Returns NULL if the cell does not exists, or it is not
  691. -- visible, or the element is not mapped.
  692. require
  693. non_negative: line >= 0
  694. column >= 0
  695. do
  696. Result := iup_open.get_attribute_id2(Current, "CELLALIGNMENT", line, column)
  697. end
  698. get_cell_offset_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER]
  699. -- Returns the cell computed offset in pixels from the top-left corner of
  700. -- the matrix, in the format [X, Y]. Returns Void if the cell does not
  701. -- exists, or it is not visible, or the element is not mapped. It will
  702. -- only return a valid result if the cell has already been displayed.
  703. -- They are similar to the parameters of the DRAW_CB callback but they do
  704. -- NOT include the decorations.
  705. require
  706. non_negative: line >= 0
  707. column >= 0
  708. local
  709. str: STRING
  710. do
  711. str := iup_open.get_attribute_id2(Current, "CELLOFFSET", line, column)
  712. Result := components_of_size (str)
  713. end
  714. get_cell_size_at (line, column: INTEGER): TUPLE[INTEGER, INTEGER]
  715. -- Returns the cell computed size in pixels, in the format [W, H].
  716. -- Returns Void if the cell does not exists, or the element is not
  717. -- mapped. It will only return a valid result if the cell has already
  718. -- been displayed. They are similar to the parameters of the DRAW_CB
  719. -- callback but they do NOT include the decorations.
  720. require
  721. non_negative: line >= 0
  722. column >= 0
  723. local
  724. str: STRING
  725. do
  726. str := iup_open.get_attribute_id2(Current, "CELLSIZE", line, column)
  727. Result := components_of_size (str)
  728. end
  729. -- Column/Line Only Attributes (no redraw)
  730. set_horizontal_alignment_at_column (value: STRING; column: INTEGER)
  731. -- Horizontal alignment of the cells in column (column >= 0) for lines
  732. -- that greater than 0. Can be: "ALEFT", "ACENTER" or "ARIGHT". Default:
  733. -- "ALEFT" for column=0 and "ACENTER" for column>0. Before checking the
  734. -- default value it will check the "ALIGNMENT" attribute value. If the
  735. -- text do not fit in the cell then the alignment is changed to "ALEFT".
  736. require
  737. valid: column >= 0
  738. is_valid_col_align(value)
  739. do
  740. iup_open.set_attribute_id(Current, "ALIGNMENT", column, value)
  741. end
  742. get_horizontal_alignment_at_column (column: INTEGER): STRING
  743. require
  744. non_negative: column >= 0
  745. do
  746. Result := iup_open.get_attribute_id(Current, "ALIGNMENT", column)
  747. end
  748. set_alignment_line_0 (value: STRING)
  749. -- Horizontal alignment of all the cells in line 0. Default is "ACENTER".
  750. require
  751. valid: is_valid_col_align(value)
  752. do
  753. iup_open.set_attribute(Current, "ALIGNMENTLIN0", value)
  754. end
  755. get_alignment_line_0: STRING
  756. do
  757. Result := iup_open.get_attribute(Current, "ALIGNMENTLIN0")
  758. end
  759. set_vertical_alignment_at_line (value: STRING; line: INTEGER)
  760. -- Vertical alignment of the cells in line (line >= 0) for all columns.
  761. -- Can be: "ATOP", "ACENTER" or "ABOTTOM". Default is "ACENTER".
  762. require
  763. valid: line >= 0
  764. is_valid_lin_align(value)
  765. do
  766. iup_open.set_attribute_id(Current, "LINEALIGNMENT", line, value)
  767. end
  768. get_vertical_alignment_at_line (line: INTEGER): STRING
  769. require
  770. non_negative: line >= 0
  771. do
  772. Result := iup_open.get_attribute_id(Current, "LINEALIGNMENT", line)
  773. end
  774. set_sort_sign_at_column (value: STRING; column: INTEGER)
  775. -- Shows a sort sign (up or down arrow) in the column (column >= 0)
  776. -- title. Possible values: "UP", "DOWN" and "NO". Default: NO.
  777. require
  778. valid: column >= 0
  779. is_valid_sort_sign(value)
  780. do
  781. iup_open.set_attribute_id(Current, "SORTSIGN", column, value)
  782. end
  783. get_sort_sign_at_column (column: INTEGER): STRING
  784. do
  785. Result := iup_open.get_attribute_id(Current, "SORTSIGN", column)
  786. end
  787. set_sort_image_down (name: STRING)
  788. -- Sort sign image name. Use "set_attribute_handle" associate an image to
  789. -- a name. See also IUP_IMAGE. By default an internal image will be used.
  790. do
  791. iup_open.set_attribute(Current, "SORTIMAGEDOWN", name)
  792. end
  793. get_sort_image_down: STRING
  794. do
  795. Result := iup_open.get_attribute(Current, "SORTIMAGEDOWN")
  796. end
  797. set_sort_image_up (name: STRING)
  798. -- Sort sign image name. Use "set_attribute_handle" associate an image to
  799. -- a name. See also IUP_IMAGE. By default an internal image will be used.
  800. do
  801. iup_open.set_attribute(Current, "SORTIMAGEUP", name)
  802. end
  803. get_sort_image_up: STRING
  804. do
  805. Result := iup_open.get_attribute(Current, "SORTIMAGEUP")
  806. end
  807. -- Size Attributes
  808. set_limit_expand (state: BOOLEAN)
  809. -- Limit expansion to the maximum size that shows all cells. This will
  810. -- set the MAXSIZE attribute to match the natural size of the matrix when
  811. -- all cells are visible. When the scrollbars have *AUTOHIDE=True, the
  812. -- maximum size will not include the scrollbars.
  813. do
  814. iup_open.set_attribute(Current, "LIMITEXPAND", boolean_to_yesno(state))
  815. end
  816. is_limit_expand: BOOLEAN
  817. local
  818. str: STRING
  819. do
  820. str := iup_open.get_attribute(Current, "LIMITEXPAND")
  821. Result := yesno_to_boolean(str)
  822. end
  823. set_resize_matrix (state: BOOLEAN)
  824. -- Defines if the width of a column can be interactively changed. When
  825. -- this is possible, the user can change the size of a column by dragging
  826. -- the column title right border. Default: "False" (does not allow
  827. -- interactive width change).
  828. do
  829. iup_open.set_attribute(Current, "RESIZEMATRIX", boolean_to_yesno(state))
  830. end
  831. is_resize_matrix: BOOLEAN
  832. local
  833. str: STRING
  834. do
  835. str := iup_open.get_attribute(Current, "RESIZEMATRIX")
  836. Result := yesno_to_boolean(str)
  837. end
  838. set_resize_drag (state: BOOLEAN)
  839. -- Resize the column while dragging. By default the column is resized
  840. -- only when the mouse button is released, the resize feedback is a
  841. -- simple vertical line. Works only when set_resize_matrix=True.
  842. -- Default: False.
  843. do
  844. iup_open.set_attribute(Current, "RESIZEDRAG", boolean_to_yesno(state))
  845. end
  846. set_use_title_size (state: BOOLEAN)
  847. -- Use the title size to define the cell size if necessary. See WIDTHn and
  848. -- HEIGHTn. Default: False.
  849. do
  850. iup_open.set_attribute(Current, "USETITLESIZE", boolean_to_yesno(state))
  851. end
  852. is_use_title_size: BOOLEAN
  853. local
  854. str: STRING
  855. do
  856. str := iup_open.get_attribute(Current, "USETITLESIZE")
  857. Result := yesno_to_boolean(str)
  858. end
  859. -- Column Size Attributes
  860. set_width_at_column (width, column: INTEGER)
  861. -- Width of column n in SIZE units, where n is the number of the column
  862. -- (n>=0). If the width value is 0, the column will not be shown on the
  863. -- screen. It does not includes the decoration size occupied by the frame
  864. -- lines.
  865. require
  866. non_negative: width >= 0
  867. column >= 0
  868. do
  869. iup_open.set_attribute_id(Current, "WIDTH", column, width.to_string)
  870. end
  871. get_width_at_column (column: INTEGER): INTEGER
  872. require
  873. non_negative: column >= 0
  874. do
  875. Result := iup_open.get_attribute_id(Current, "WIDTH", column).to_integer
  876. end
  877. set_default_width (width: INTEGER)
  878. -- Default column width in SIZE units. Not used for the title column.
  879. -- Default: 80 (width corresponding to 20 characters).
  880. require
  881. non_negative: width >= 0
  882. do
  883. iup_open.set_attribute(Current, "WIDTHDEF", width.to_string)
  884. end
  885. get_default_width: INTEGER
  886. do
  887. Result := iup_open.get_attribute(Current, "WIDTHDEF").to_integer
  888. end
  889. set_raster_width_at_column (width, column: INTEGER)
  890. -- Same as "set_width_at_column" but in pixels. Has lower priority than
  891. -- "set_width_at_column".
  892. require
  893. non_negative: width >= 0
  894. column >= 0
  895. do
  896. iup_open.set_attribute_id(Current, "RASTERWIDTH", column, width.to_string)
  897. end
  898. get_raster_width_at_column (column: INTEGER): INTEGER
  899. require
  900. non_negative: column >= 0
  901. do
  902. Result := iup_open.get_attribute_id(Current, "RASTERWIDTH", column).to_integer
  903. end
  904. set_min_width_at_column (width, column: INTEGER)
  905. -- When the column is interactively resized controls the minimum width of
  906. -- the given column. If not defined the min width column is used.
  907. require
  908. non_negative: width >= 0
  909. column >= 0
  910. do
  911. iup_open.set_attribute_id(Current, "MINCOLWIDTH", column, width.to_string)
  912. end
  913. set_default_min_width (width: INTEGER)
  914. require
  915. non_negative: width >= 0
  916. do
  917. iup_open.set_attribute(Current, "MINCOLWIDTHDEF", width.to_string)
  918. end
  919. -- Line Size Attributes
  920. set_height_at_line (height, line: INTEGER)
  921. -- Height of line n in SIZE units, where n is the number of the line
  922. -- (n>=0). If the height value is 0, the line will not be shown on the
  923. -- screen. It does not includes the decoration size occupied by the frame
  924. -- lines.
  925. require
  926. non_negative: height >= 0
  927. line >= 0
  928. do
  929. iup_open.set_attribute_id(Current, "HEIGHT", line, height.to_string)
  930. end
  931. get_height_at_line (line: INTEGER): INTEGER
  932. require
  933. non_negative: line >= 0
  934. do
  935. Result := iup_open.get_attribute_id(Current, "HEIGHT", line).to_integer
  936. end
  937. set_default_height (height: INTEGER)
  938. -- Default line height in SIZE units. Not used for the title line.
  939. -- Default: 8 (height corresponding to 1 line).
  940. require
  941. non_negative: height >= 0
  942. do
  943. iup_open.set_attribute(Current, "HEIGHTDEF", height.to_string)
  944. end
  945. get_default_height: INTEGER
  946. do
  947. Result := iup_open.get_attribute(Current, "HEIGHTDEF").to_integer
  948. end
  949. set_raster_height_at_line (height, line: INTEGER)
  950. -- Same as "set_height_at_line" but in pixels. Has lower priority than
  951. -- "set_height_at_line".
  952. require
  953. non_negative: height >= 0
  954. line >= 0
  955. do
  956. iup_open.set_attribute_id(Current, "RASTERHEIGHT", line, height.to_string)
  957. end
  958. get_raster_height_at_line (line: INTEGER): INTEGER
  959. require
  960. non_negative: line >= 0
  961. do
  962. Result := iup_open.get_attribute_id(Current, "RASTERHEIGHT", line).to_integer
  963. end
  964. -- Number of Cells Attributes
  965. add_column (reference: INTEGER)
  966. -- Adds a new column to the matrix after the specified column. To insert
  967. -- a column at the top of the spreadsheet, value 0 must be used. It can
  968. -- be used in normal operation mode or in callback mode, but in callback
  969. -- mode will not update cell values this must be done by the application.
  970. -- Can NOT add a title column. Ignored if set before map.
  971. require
  972. non_negative: reference >= 0
  973. do
  974. iup_open.set_attribute(Current, "ADDCOL", reference.to_string)
  975. end
  976. add_columns (reference, count: INTEGER)
  977. -- The first number corresponds to the base column and the second number
  978. -- corresponds to the number of columns to be added. It can be used in
  979. -- normal operation mode or in callback mode, but in callback mode will
  980. -- not update cell values this must be done by the application. To insert
  981. -- columns at the top of the spreadsheet, value 0 must be used as
  982. -- reference. Can NOT add a title column. Ignored if set before map.
  983. require
  984. non_negative: reference >= 0
  985. count > 0
  986. local
  987. str: STRING
  988. do
  989. str := reference.to_string
  990. str.append_string("-")
  991. str.append_string(count.to_string)
  992. iup_open.set_attribute(Current, "ADDCOL", str)
  993. end
  994. add_line (reference: INTEGER)
  995. -- Adds a new line to the matrix after the specified line. To insert a
  996. -- line at the top of the spreadsheet, value 0 must be used. It can be
  997. -- used in normal operation mode or in callback mode, but in callback
  998. -- mode will not update cell values this must be done by the application.
  999. -- Can NOT add a title line. Ignored if set before map.
  1000. require
  1001. non_negative: reference >= 0
  1002. do
  1003. iup_open.set_attribute(Current, "ADDLIN", reference.to_string)
  1004. end
  1005. add_lines (reference, count: INTEGER)
  1006. -- The first number corresponds to the base line and the second number
  1007. -- corresponds to the number of lines to be added. It can be used in
  1008. -- normal operation mode or in callback mode, but in callback mode will
  1009. -- not update cell values this must be done by the application. To insert
  1010. -- lines at the top of the spreadsheet, value 0 must be used.Can NOT
  1011. -- add a title line. Ignored if set before map.
  1012. require
  1013. non_negative: reference >= 0
  1014. count > 0
  1015. local
  1016. str: STRING
  1017. do
  1018. str := reference.to_string
  1019. str.append_string("-")
  1020. str.append_string(count.to_string)
  1021. iup_open.set_attribute(Current, "ADDLIN", str)
  1022. end
  1023. delete_column (reference: INTEGER)
  1024. -- Removes the given column from the matrix. It can be used in normal
  1025. -- operation mode or in callback mode, but in callback mode will not
  1026. -- update cell values this must be done by the application. Can NOT
  1027. -- remove a title column, reference > 0. Ignored if set before map.
  1028. require
  1029. reference > 0
  1030. do
  1031. iup_open.set_attribute(Current, "DELCOL", reference.to_string)
  1032. end
  1033. delete_columns (reference, count: INTEGER)
  1034. -- The first number corresponds to the base column and the second number
  1035. -- corresponds to the number of columns to be removed. It can be used in
  1036. -- normal operation mode or in callback mode, but in callback mode will
  1037. -- not update cell values this must be done by the application. Can NOT
  1038. -- remove a title column, reference > 0. Ignored if set before map.
  1039. require
  1040. reference > 0
  1041. count > 0
  1042. local
  1043. str: STRING
  1044. do
  1045. str := reference.to_string
  1046. str.append_string("-")
  1047. str.append_string(count.to_string)
  1048. iup_open.set_attribute(Current, "DELCOL", str)
  1049. end
  1050. delete_line (reference: INTEGER)
  1051. -- Removes the given line from the matrix. It can be used in normal
  1052. -- operation mode or in callback mode, but in callback mode will not
  1053. -- update cell values this must be done by the application. Can NOT
  1054. -- remove a title line, reference > 0. Ignored if set before map.
  1055. require
  1056. reference > 0
  1057. do
  1058. iup_open.set_attribute(Current, "DELLIN", reference.to_string)
  1059. end
  1060. delete_lines (reference, count: INTEGER)
  1061. -- The first number corresponds to the base line and the second number
  1062. -- corresponds to the number of lines to be removed. It can be used in
  1063. -- normal operation mode or in callback mode, but in callback mode will
  1064. -- not update cell values this must be done by the application. Can NOT
  1065. -- remove a title line, reference > 0. Ignored if set before map.
  1066. require
  1067. reference > 0
  1068. count > 0
  1069. local
  1070. str: STRING
  1071. do
  1072. str := reference.to_string
  1073. str.append_string("-")
  1074. str.append_string(count.to_string)
  1075. iup_open.set_attribute(Current, "DELLIN", str)
  1076. end
  1077. set_number_of_columns (count: INTEGER)
  1078. -- Defines the number of columns in the matrix. Default: "0". It does not
  1079. -- include the title column. If changed after map will add empty cells or
  1080. -- discard cells at the end.
  1081. require
  1082. non_negative: count >= 0
  1083. do
  1084. iup_open.set_attribute(Current, "NUMCOL", count.to_string)
  1085. end
  1086. get_number_of_columns: INTEGER
  1087. do
  1088. Result := iup_open.get_attribute(Current, "NUMCOL").to_integer
  1089. end
  1090. set_number_of_visible_columns (count: INTEGER)
  1091. -- When set defines the number of visible columns to be counted when
  1092. -- calculating the Natural size, not counting the title column. Not used
  1093. -- elsewhere. The Natural size will always include the title column if
  1094. -- any. Can be greater than the actual number of columns, so room will be
  1095. -- reserved for adding new columns without the need to resize the matrix.
  1096. -- Also it will always use the first columns of the matrix, except if
  1097. -- "set_visible_last_columns" is set to True then it will use the last
  1098. -- columns. The remaining columns will be accessible only by using the
  1099. -- scrollbar. Default: "4".
  1100. require
  1101. non_negative: count >= 0
  1102. do
  1103. iup_open.set_attribute(Current, "NUMCOL_VISIBLE", count.to_string)
  1104. end
  1105. get_number_of_visible_columns: INTEGER
  1106. -- Returns the current number of visible columns, not including the non
  1107. -- scrollable columns.
  1108. do
  1109. Result := iup_open.get_attribute(Current, "NUMCOL_VISIBLE").to_integer
  1110. end
  1111. set_number_of_non_scrollable_columns (count: INTEGER)
  1112. -- Number of columns that are non scrollable, not counting the title
  1113. -- column. Default: "0". It does not affect the "visible columns"
  1114. -- attribute behavior nor Natural size computation. It will always use
  1115. -- the first columns of the matrix. The cells appearance will be the same
  1116. -- of ordinary cells, and they can also receive the focus and be edited.
  1117. -- Must be less than the total number of columns.
  1118. require
  1119. non_negative: count >= 0
  1120. do
  1121. iup_open.set_attribute(Current, "NUMCOL_NOSCROLL", count.to_string)
  1122. end
  1123. set_visible_last_columns (state: BOOLEAN)
  1124. do
  1125. iup_open.set_attribute(Current, "NUMCOL_VISIBLE_LAST", boolean_to_yesno(state))
  1126. end
  1127. set_number_of_lines (count: INTEGER)
  1128. -- Defines the number of lines in the matrix. Default: "0". It does not
  1129. -- include the title line. If changed after map will add empty cells or
  1130. -- discard cells at the end.
  1131. require
  1132. non_negative: count >= 0
  1133. do
  1134. iup_open.set_attribute(Current, "NUMLIN", count.to_string)
  1135. end
  1136. get_number_of_lines: INTEGER
  1137. do
  1138. Result := iup_open.get_attribute(Current, "NUMLIN").to_integer
  1139. end
  1140. set_number_of_visible_lines (count: INTEGER)
  1141. -- When set defines the number of visible lines to be counted when
  1142. -- calculating the Natural size, not counting the title line. Not used
  1143. -- elsewhere. The Natural size will always include the title line if any.
  1144. -- Can be greater than the actual number of lines, so room will be
  1145. -- reserved for adding new lines without the need to resize the matrix.
  1146. -- Also it will always use the first lines of the matrix, except
  1147. -- "set_last_visible_columns" is set the True then it will use the last
  1148. -- lines. The remaining lines will be accessible only by using the
  1149. -- scrollbar.
  1150. require
  1151. non_negative: count >= 0
  1152. do
  1153. iup_open.set_attribute(Current, "NUMLIN_VISIBLE", count.to_string)
  1154. end
  1155. get_number_of_visible_lines: INTEGER
  1156. -- Returns the current number of visible lines, not including the non
  1157. -- scrollable lines. Default: "3".
  1158. do
  1159. Result := iup_open.get_attribute(Current, "NUMLIN_VISIBLE").to_integer
  1160. end
  1161. set_number_of_non_scrollable_lines (count: INTEGER)
  1162. -- Number of lines that are non scrollable, not counting the title line.
  1163. -- Default: "0". It does not affect the "visible lines" attribute
  1164. -- behavior nor Natural size computation. It will always use the first
  1165. -- lines of the matrix. The cells appearance will be the same of ordinary
  1166. -- cells, and they can also receive the focus and be edited. Must be less
  1167. -- than the total number of lines.
  1168. require
  1169. non_negative: count >= 0
  1170. do
  1171. iup_open.set_attribute(Current, "NUMLIN_NOSCROLL", count.to_string)
  1172. end
  1173. set_visible_last_lines (state: BOOLEAN)
  1174. do
  1175. iup_open.set_attribute(Current, "NUMLIN_VISIBLE_LAST", boolean_to_yesno(state))
  1176. end
  1177. set_no_scroll_as_title (state: BOOLEAN)
  1178. -- Non scrollable lines and columns to look and behave as title cells.
  1179. -- Default: "False".
  1180. do
  1181. iup_open.set_attribute(Current, "NOSCROLLASTITLE", boolean_to_yesno(state))
  1182. end
  1183. -- Mark Attributes
  1184. set_mark_area_continuous
  1185. -- Defines that the area to be interactively marked by the user must be
  1186. -- continuous, valid only if "mark multiple" is set to True.
  1187. -- Continuous is the default value.
  1188. do
  1189. iup_open.set_attribute(Current, "MARKAREA", "CONTINUOUS")
  1190. end
  1191. set_mark_area_not_continuous
  1192. -- Defines that the area to be interactively marked by the user could be
  1193. -- continuous or not, valid only if "mark multiple" is set to True.
  1194. do
  1195. iup_open.set_attribute(Current, "MARKAREA", "NOT_CONTINUOUS")
  1196. end
  1197. set_mark_at_title (state: BOOLEAN)
  1198. -- A click at a title will mark a full line or a full column if they can
  1199. -- be marked. Default: "True".
  1200. do
  1201. iup_open.set_attribute(Current, "MARKATTITLE", boolean_to_yesno(state))
  1202. end
  1203. set_mark_mode_no
  1204. -- No mark. This is the default value.
  1205. do
  1206. iup_open.set_attribute(Current, "MARKMODE", "NO")
  1207. end
  1208. set_mark_mode_lines
  1209. -- Defines lines as the entity that can be marked.
  1210. do
  1211. iup_open.set_attribute(Current, "MARKMODE", "LIN")
  1212. end
  1213. set_mark_mode_columns
  1214. -- Defines columns as the entity that can be marked.
  1215. do
  1216. iup_open.set_attribute(Current, "MARKMODE", "COL")
  1217. end
  1218. set_mark_mode_lines_and_columns
  1219. -- Defines lines and columns as the entity that can be marked.
  1220. do
  1221. iup_open.set_attribute(Current, "MARKMODE", "LINCOL")
  1222. end
  1223. set_mark_mode_cell
  1224. -- Defines cells as the entity that can be marked.
  1225. do
  1226. iup_open.set_attribute(Current, "MARKMODE", "CELL")
  1227. end
  1228. mark_cell (line, column: INTEGER)
  1229. -- (no redraw) Even when mark mode is "lines", "columns" or "lines and
  1230. -- columns" you can specify a single cell address.
  1231. require
  1232. line > 0
  1233. column > 0
  1234. do
  1235. iup_open.set_attribute_id2(Current, "MARK", line, column, "1")
  1236. end
  1237. unmark_cell (line, column: INTEGER)
  1238. -- (no redraw)
  1239. require
  1240. line > 0
  1241. column > 0
  1242. do
  1243. iup_open.set_attribute_id2(Current, "MARK", line, column, "0")
  1244. end
  1245. is_marked_cell (line, column: INTEGER): BOOLEAN
  1246. require
  1247. line > 0
  1248. column > 0
  1249. local
  1250. str: STRING
  1251. do
  1252. str := iup_open.get_attribute_id2(Current, "MARK", line, column)
  1253. Result := string_to_boolean(str)
  1254. end
  1255. mark_line (line: INTEGER)
  1256. -- (no redraw)
  1257. require
  1258. line > 0
  1259. do
  1260. iup_open.set_attribute_id2(Current, "MARK", line, 0, "1")
  1261. end
  1262. unmark_line (line: INTEGER)
  1263. -- (no redraw)
  1264. require
  1265. line > 0
  1266. do
  1267. iup_open.set_attribute_id2(Current, "MARK", line, 0, "0")
  1268. end
  1269. is_marked_line (line: INTEGER): BOOLEAN
  1270. require
  1271. line > 0
  1272. local
  1273. str: STRING
  1274. do
  1275. str := iup_open.get_attribute_id2(Current, "MARK", line, 0)
  1276. Result := string_to_boolean(str)
  1277. end
  1278. mark_column (column: INTEGER)
  1279. -- (no redraw)
  1280. require
  1281. column > 0
  1282. do
  1283. iup_open.set_attribute_id2(Current, "MARK", 0, column, "1")
  1284. end
  1285. unmark_column (column: INTEGER)
  1286. -- (no redraw)
  1287. require
  1288. column > 0
  1289. do
  1290. iup_open.set_attribute_id2(Current, "MARK", 0, column, "0")
  1291. end
  1292. is_marked_column (column: INTEGER): BOOLEAN
  1293. require
  1294. column > 0
  1295. local
  1296. str: STRING
  1297. do
  1298. str := iup_open.get_attribute_id2(Current, "MARK", 0, column)
  1299. Result := string_to_boolean(str)
  1300. end
  1301. clear_marks
  1302. -- Clear all marks.
  1303. do
  1304. iup_open.set_attribute_null(Current, "MARKED")
  1305. end
  1306. mark_cells (values: FAST_ARRAY2[BOOLEAN])
  1307. -- An array2 with number of lines x number of columns positions,
  1308. -- corresponding to all the cells in the matrix starting with all the
  1309. -- cells of the first line, then the second line and so on. All
  1310. -- the positions with True value will be marked.
  1311. do
  1312. iup_open.set_attribute(Current, "MARKED", array2_to_marks(values))
  1313. end
  1314. marked_cells: FAST_ARRAY2[BOOLEAN]
  1315. local
  1316. str: STRING
  1317. do
  1318. str := iup_open.get_attribute(Current, "MARKED")
  1319. if not str.first.is_equal('L') and
  1320. not str.first.is_equal('C') then
  1321. Result := marks_to_array2(str)
  1322. end
  1323. end
  1324. mark_lines (values: FAST_ARRAY[BOOLEAN])
  1325. do
  1326. iup_open.set_attribute(Current, "MARKED", "L" + array_to_marks(values))
  1327. end
  1328. marked_lines: FAST_ARRAY[BOOLEAN]
  1329. local
  1330. str: STRING
  1331. do
  1332. str := iup_open.get_attribute(Current, "MARKED")
  1333. if str.first.is_equal('L') then
  1334. str.remove_first
  1335. Result := marks_to_array(str, get_number_of_lines)
  1336. end
  1337. end
  1338. mark_columns (values: FAST_ARRAY[BOOLEAN])
  1339. do
  1340. iup_open.set_attribute(Current, "MARKED", "C" + array_to_marks(values))
  1341. end
  1342. marked_columns: FAST_ARRAY[BOOLEAN]
  1343. local
  1344. str: STRING
  1345. do
  1346. str := iup_open.get_attribute(Current, "MARKED")
  1347. if str.first.is_equal('C') then
  1348. str.remove_first
  1349. Result := marks_to_array(str, get_number_of_columns)
  1350. end
  1351. end
  1352. set_mark_multiple (state: BOOLEAN)
  1353. -- Defines if more than one entity defined by mark mode can be
  1354. -- interactively marked. Default: "False".
  1355. do
  1356. iup_open.set_attribute(Current, "MARKMULTIPLE", boolean_to_yesno(state))
  1357. end
  1358. -- Merge Attributes
  1359. merge_range (line1, column1, line2, column2: INTEGER)
  1360. -- Merge a range of cells starting from the given "linne1:column1", and
  1361. -- ending at the given "line2:column2". Title cells can also be merge but
  1362. -- only among them, i.e. in the line of column titles (L=0) can only
  1363. -- merge columns, and in the column of line titles (C=0) can only merge
  1364. -- lines. The corner cell (0:0) can not be merged with any other cell.
  1365. -- Only cells that are not already merged can be merged into a range.
  1366. require
  1367. non_negative: line1 >= 0
  1368. column1 > 0
  1369. line2 >= 0
  1370. column2 >= 0
  1371. local
  1372. str: STRING
  1373. do
  1374. str := line2.to_string
  1375. str.append_string(":")
  1376. str.append_string(column2.to_string)
  1377. iup_open.set_attribute_id2(Current, "MERGE", line1, column2, str)
  1378. end
  1379. is_merged_cell (line, column: INTEGER): BOOLEAN
  1380. -- Returns if the given cell belongs to a merged range.
  1381. require
  1382. non_negative: line >= 0
  1383. column > 0
  1384. local
  1385. str: STRING
  1386. do
  1387. str := iup_open.get_attribute_id2(Current, "MERGE", line, column)
  1388. Result := yesno_to_boolean(str)
  1389. end
  1390. split_a_merged_range (line, column: INTEGER)
  1391. -- Split a merged range. value is a cell "lin:col" than belongs to the
  1392. -- range, any cell of the range can be used.
  1393. require
  1394. non_negative: line >= 0
  1395. column > 0
  1396. local
  1397. str: STRING
  1398. do
  1399. str := line.to_string
  1400. str.append_string(":")
  1401. str.append_string(column.to_string)
  1402. iup_open.set_attribute(Current, "MERGESPLIT", str)
  1403. end
  1404. range_start (line, column: INTEGER): TUPLE[INTEGER, INTEGER]
  1405. -- Returns the start cell of the range given a cell that belongs to the
  1406. -- range, any cell of the range can be used.
  1407. local
  1408. str: STRING
  1409. do
  1410. str := iup_open.get_attribute_id2(Current, "MERGEDSTART", line, column)
  1411. Result := components_of (str, ':')
  1412. end
  1413. range_end (line, column: INTEGER): TUPLE[INTEGER, INTEGER]
  1414. -- Returns the end cell of the range given a cell that belongs to the
  1415. -- range, any cell of the range can be used.
  1416. local
  1417. str: STRING
  1418. do
  1419. str := iup_open.get_attribute_id2(Current, "MERGEDEND", line, column)
  1420. Result := components_of (str, ':')
  1421. end
  1422. -- Action Attributes
  1423. clear_all_attributes
  1424. -- Clear all cell attributes, all lines and column attributes are also
  1425. -- cleared.
  1426. do
  1427. iup_open.set_attribute(Current, "CLEARATTRIB", "ALL")
  1428. end
  1429. clear_all_attributes_except_contents
  1430. -- Clear all cell attributes, except titles.
  1431. do
  1432. iup_open.set_attribute(Current, "CLEARATTRIB", "CONTENTS")
  1433. end
  1434. clear_all_attributes_at_marked_cells
  1435. -- Clear all cell attributes at selected cells.
  1436. do
  1437. iup_open.set_attribute(Current, "CLEARATTRIB", "MARKED")
  1438. end
  1439. clear_all_attributes_at_interval (line1, column1, line2, column2: INTEGER)
  1440. -- Clear all cell attributes in the interval starting at cell 1
  1441. -- and ending at cell 2.
  1442. require
  1443. line1 >= 0
  1444. column1 >= 0
  1445. line2 >= 0
  1446. column2 >= 0
  1447. local
  1448. str: STRING
  1449. do
  1450. str := line2.to_string
  1451. str.append_string(":")
  1452. str.append_string(column2.to_string)
  1453. iup_open.set_attribute_id2(Current, "CLEARATTRIB", line1, column1, str)
  1454. end
  1455. clear_all_line_attributes_at_interval (line, column1, column2: INTEGER)
  1456. -- Clear the cell attributes in line at interval "column1-column2". When
  1457. -- a full line is specified, all line attributes are also cleared.
  1458. require
  1459. line >= 0
  1460. column1 >= 0
  1461. column2 >= 0
  1462. local
  1463. str: STRING
  1464. do
  1465. str := column1.to_string
  1466. str.append_string("-")
  1467. str.append_string(column2.to_string)
  1468. iup_open.set_attribute_id2(Current, "CLEARATTRIB", line, -10, str)
  1469. end
  1470. clear_all_column_attributes_at_interval (column, line1, line2: INTEGER)
  1471. -- Clear the cell attributes in column C at interval "line1-line2". When
  1472. -- a full column is specified, all column attributes are also cleared,
  1473. -- including alignment and sort sign.
  1474. require
  1475. column >= 0
  1476. line1 >= 0
  1477. line2 >= 0
  1478. local
  1479. str: STRING
  1480. do
  1481. str := line1.to_string
  1482. str.append_string("-")
  1483. str.append_string(line2.to_string)
  1484. iup_open.set_attribute_id2(Current, "CLEARATTRIB", -10, column, str)
  1485. end
  1486. clear_all_values
  1487. -- Clear all values.
  1488. do
  1489. iup_open.set_attribute(Current, "CLEARVALUE", "ALL")
  1490. end
  1491. clear_all_values_except_contents
  1492. -- Clear all values, except titles.
  1493. do
  1494. iup_open.set_attribute(Current, "CLEARVALUE", "CONTENTS")
  1495. end
  1496. clear_all_values_at_marked_cells
  1497. -- Clear all values at selected cells.
  1498. do
  1499. iup_open.set_attribute(Current, "CLEARVALUE", "MARKED")
  1500. end
  1501. clear_all_values_at_interval (line1, column1, line2, column2: INTEGER)
  1502. -- Clear all values at interval starting at cell 1 and
  1503. -- ending at cell 2.
  1504. require
  1505. line1 >= 0
  1506. column1 >= 0
  1507. line2 >= 0
  1508. column2 >= 0
  1509. local
  1510. str: STRING
  1511. do
  1512. str := line2.to_string
  1513. str.append_string(":")
  1514. str.append_string(column2.to_string)
  1515. iup_open.set_attribute_id2(Current, "CLEARVALUE", line1, column1, str)
  1516. end
  1517. clear_all_line_values_at_interval (line, column1, column2: INTEGER)
  1518. -- Clear all values at line in the interval "column1-column2".
  1519. require
  1520. line >= 0
  1521. column1 >= 0
  1522. column2 >= 0
  1523. local
  1524. str: STRING
  1525. do
  1526. str := column1.to_string
  1527. str.append_string("-")
  1528. str.append_string(column2.to_string)
  1529. iup_open.set_attribute_id2(Current, "CLEARVALUE", line, -10, str)
  1530. end
  1531. clear_all_column_values_at_interval (column, line1, line2: INTEGER)
  1532. -- Clear all values at column in the interval "line1-line2".
  1533. require
  1534. column >= 0
  1535. line1 >= 0
  1536. line2 >= 0
  1537. local
  1538. str: STRING
  1539. do
  1540. str := line1.to_string
  1541. str.append_string("-")
  1542. str.append_string(line2.to_string)
  1543. iup_open.set_attribute_id2(Current, "CLEARVALUE", -10, column, str)
  1544. end
  1545. copy_column_to (source_column, target_column: INTEGER)
  1546. -- Copy the values and attributes from source_column to target_column.
  1547. require
  1548. source_column >= 0
  1549. target_column >= 0
  1550. do
  1551. iup_open.set_attribute_id(Current, "COPYCOL", source_column,
  1552. target_column.to_string)
  1553. end
  1554. copy_line_to (source_line, target_line: INTEGER)
  1555. -- Copy the values and attributes from source_line to target_line.
  1556. require
  1557. source_line >= 0
  1558. target_line >= 0
  1559. do
  1560. iup_open.set_attribute_id(Current, "COPYLIN", source_line,
  1561. target_line.to_string)
  1562. end
  1563. fit_to_size_lines
  1564. -- Force lines sizes so the matrix visible size fit in its current size.
  1565. -- number of visible lines/columns are considered when fitting and they
  1566. -- are not changed, only the raster width and raster height attributes
  1567. -- are changed. But if any of the raster width/height attributes where
  1568. -- already set, then they will not be changed. If the matrix is resized
  1569. -- then it must be set again to obtain the same result, but before doing
  1570. -- that set to Void all the raster width/height attributes that you want
  1571. -- to be changed.
  1572. do
  1573. iup_open.set_attribute(Current, "FITTOSIZE", "LINES")
  1574. end
  1575. fit_to_size_columns
  1576. -- Force columns sizes so the matrix visible size fit in its current size.
  1577. -- number of visible lines/columns are considered when fitting and they
  1578. -- are not changed, only the raster width and raster height attributes
  1579. -- are changed. But if any of the raster width/height attributes where
  1580. -- already set, then they will not be changed. If the matrix is resized
  1581. -- then it must be set again to obtain the same result, but before doing
  1582. -- that set to Void all the raster width/height attributes that you want
  1583. -- to be changed.
  1584. do
  1585. iup_open.set_attribute(Current, "FITTOSIZE", "COLUMNS")
  1586. end
  1587. fit_to_size_lines_and_columns
  1588. -- Force lines and columns sizes so the matrix visible size fit in its
  1589. -- current size. number of visible lines/columns are considered when
  1590. -- fitting and they are not changed, only the raster width and raster
  1591. -- height attributes are changed. But if any of the raster width/height
  1592. -- attributes where already set, then they will not be changed. If the
  1593. -- matrix is resized then it must be set again to obtain the same result,
  1594. -- but before doing that set to Void all the raster width/height
  1595. -- attributes that you want to be changed.
  1596. do
  1597. iup_open.set_attribute(Current, "FITTOSIZE", "YES")
  1598. end
  1599. set_fit_maximum_width_at_column (value, column: INTEGER)
  1600. -- The maximum width of the column.
  1601. require
  1602. value > 0
  1603. column >= 0
  1604. do
  1605. iup_open.set_attribute_id(Current, "FITMAXWIDTH", column, value.to_string)
  1606. end
  1607. set_fit_maximum_height_at_line (value, line: INTEGER)
  1608. -- The maximum height of the line.
  1609. require
  1610. value > 0
  1611. line >= 0
  1612. do
  1613. iup_open.set_attribute_id(Current, "FITMAXHEIGHT", line, value.to_string)
  1614. end
  1615. fit_to_text_at_column (column: INTEGER)
  1616. -- It will fit the largest text in the given column.
  1617. require
  1618. column >= 0
  1619. do
  1620. iup_open.set_attribute(Current, "FITTOTEXT", "C" + column.to_string)
  1621. end
  1622. fit_to_text_at_line (line: INTEGER)
  1623. -- It will fit the largest text in the given line.
  1624. require
  1625. line >= 0
  1626. do
  1627. iup_open.set_attribute(Current, "FITTOTEXT", "L" + line.to_string)
  1628. end
  1629. move_column_to (origin, target: INTEGER)
  1630. -- Move the values and attributes from column origin to the target
  1631. -- column. Internally will use 'add column + copy column +
  1632. -- delete column' to perform the move so it is limited to those features
  1633. -- restrictions. It can be used in normal operation mode or in callback
  1634. -- mode, but in callback mode will not update cell values, this must be
  1635. -- done by the application.
  1636. require
  1637. origin > 0
  1638. target >= 0
  1639. do
  1640. iup_open.set_attribute_id(Current, "MOVECOL", origin, target.to_string)
  1641. end
  1642. move_line_to (origin, target: INTEGER)
  1643. -- Move the values and attributes from line origin to the target
  1644. -- line. Internally will use 'add line + copy line +
  1645. -- delete line' to perform the move so it is limited to those features
  1646. -- restrictions. It can be used in normal operation mode or in callback
  1647. -- mode, but in callback mode will not update cell values, this must be
  1648. -- done by the application.
  1649. require
  1650. origin > 0
  1651. target >= 0
  1652. do
  1653. iup_open.set_attribute_id(Current, "MOVELIN", origin, target.to_string)
  1654. end
  1655. redraw_all
  1656. -- Inform the matrix that the data has changed, and it must be redrawn.
  1657. -- No redraw is done when the application change text at some
  1658. -- cell, or the alignment, back/fore ground color, font, value,
  1659. -- frame color or mark. Global and size attributes always automatically
  1660. -- redraw the matrix. The same applies for other redraw features.
  1661. do
  1662. iup_open.set_attribute(Current, "REDRAW", "ALL")
  1663. end
  1664. redraw_line (line: INTEGER)
  1665. -- Inform the matrix that the line data has changed, and it must be
  1666. -- redrawn.
  1667. require
  1668. line >= 0
  1669. do
  1670. iup_open.set_attribute(Current, "REDRAW", "L" + line.to_string)
  1671. end
  1672. redraw_column (column: INTEGER)
  1673. -- Inform the matrix that the column data has changed, and it must be
  1674. -- redrawn.
  1675. require
  1676. column >= 0
  1677. do
  1678. iup_open.set_attribute(Current, "REDRAW", "C" + column.to_string)
  1679. end
  1680. redraw_lines_in_region (start_line, end_line: INTEGER)
  1681. -- Inform the matrix that the data in the region has changed, and it must
  1682. -- be redrawn.
  1683. require
  1684. start_line >= 0
  1685. end_line > 0
  1686. do
  1687. iup_open.set_attribute(Current, "REDRAW", "L" + start_line.to_string +
  1688. "-" + end_line.to_string)
  1689. end
  1690. redraw_columns_in_region (start_column, end_column: INTEGER)
  1691. -- Inform the matrix that the data in the region has changed, and it must
  1692. -- be redrawn.
  1693. require
  1694. start_column >= 0
  1695. end_column > 0
  1696. do
  1697. iup_open.set_attribute(Current, "REDRAW", "C" +
  1698. start_column.to_string + "-" +
  1699. end_column.to_string)
  1700. end
  1701. show_cell (line, column: INTEGER)
  1702. -- If necessary scroll the visible area to make the given cell visible.
  1703. require
  1704. line > 0
  1705. column > 0
  1706. do
  1707. iup_open.set_attribute(Current, "SHOW", line.to_string + ":" +
  1708. column.to_string)
  1709. end
  1710. show_line (line: INTEGER)
  1711. -- If necessary scroll the visible area to make the given line visible.
  1712. require
  1713. line > 0
  1714. do
  1715. iup_open.set_attribute(Current, "SHOW", line.to_string + ":*")
  1716. end
  1717. show_column (column: INTEGER)
  1718. -- If necessary scroll the visible area to make the given column visible.
  1719. require
  1720. column > 0
  1721. do
  1722. iup_open.set_attribute(Current, "SHOW", "*:" + column.to_string)
  1723. end
  1724. -- Editing Attributes
  1725. set_edit_mode (state: BOOLEAN)
  1726. -- When set to True, programmatically puts the current cell in edition
  1727. -- mode, allowing the user to modify its value.
  1728. do
  1729. iup_open.set_attribute(Current, "EDITMODE", boolean_to_yesno(state))
  1730. end
  1731. is_visible_editing_control: BOOLEAN
  1732. -- Informs if the editing control is visible (text or dropdown).
  1733. local
  1734. str: STRING
  1735. do
  1736. str := iup_open.get_attribute(Current, "EDITMODE")
  1737. Result := yesno_to_boolean(str)
  1738. end
  1739. set_edit_alignment (state: BOOLEAN)
  1740. -- Sets the text box alignment to the column alignment when editing a
  1741. -- cell value. Default: False.
  1742. do
  1743. iup_open.set_attribute(Current, "EDITALIGN", boolean_to_yesno(state))
  1744. end
  1745. get_edited_cell: TUPLE[INTEGER, INTEGER]
  1746. -- Returns the current cell being edited [line, column], or Void if
  1747. -- none. Can also be used during interaction while editing is being
  1748. -- performed and 'edit hide on focus' is False.
  1749. local
  1750. str: STRING
  1751. do
  1752. str := iup_open.get_attribute(Current, "EDITCELL")
  1753. if str /= Void then
  1754. Result := components_of (str, ':')
  1755. end
  1756. end
  1757. set_edit_fit_value (state: BOOLEAN)
  1758. -- Enable a text box larger than the cell size of necessary, according to
  1759. -- the cell font and cell current value. While editing if more room is
  1760. -- necessary it will grow to the right. Default: False.
  1761. do
  1762. iup_open.set_attribute(Current, "EDITFITVALUE", boolean_to_yesno(state))
  1763. end
  1764. set_edit_hide_on_focus (state: BOOLEAN)
  1765. -- When editing a cell if text box loses its focus, then editing ends.
  1766. -- Default: True. When set to False editing will continue and the matrix
  1767. -- can be scrolled, also when pressing Esc or Enter if the focus is at
  1768. -- the matrix it has the same effect as if pressed at the text box.
  1769. do
  1770. iup_open.set_attribute(Current, "EDITHIDEONFOCUS", boolean_to_yesno(state))
  1771. end
  1772. is_editing: BOOLEAN
  1773. -- Returns True if the editing process is active for text or dropdown. It
  1774. -- is set to True after EDITION_CB, after MENUDROP_CB, before DROP_CB and
  1775. -- before the editing control is made visible. Set to False when editing
  1776. -- is about to end, after EDITION_CB and after the value has been
  1777. -- updated, but before the editing control is made invisible.
  1778. local
  1779. str: STRING
  1780. do
  1781. str := iup_open.get_attribute(Current, "EDITING")
  1782. Result := yesno_to_boolean(str)
  1783. end
  1784. set_edit_next (value: STRING)
  1785. -- Controls how the next cell after editing is chosen. Can be LIN, COL,
  1786. -- LINCR, COLCR. Default: LIN.
  1787. --
  1788. -- LIN - go to the next line, if at last line then go to the next column
  1789. -- at the same line;
  1790. -- LINCR - go to the next line, if at last line then go to the next
  1791. -- column at the first line;
  1792. -- COL - go to the next column, if at last column then go to the next
  1793. -- line at the same column;
  1794. -- COLCR - go to the next column, if at last column then go to the next
  1795. -- line at the first column;
  1796. -- NONE - stay in the same cell.
  1797. require
  1798. is_valid_edit_next(value)
  1799. do
  1800. iup_open.set_attribute(Current, "EDITNEXT", value)
  1801. end
  1802. is_edit_text: BOOLEAN
  1803. -- Returns True if the editing is being done by a text box.
  1804. local
  1805. str: STRING
  1806. do
  1807. str := iup_open.get_attribute(Current, "EDITTEXT")
  1808. Result := yesno_to_boolean(str)
  1809. end
  1810. is_edit_value: BOOLEAN
  1811. -- Returns True if the display cell value being consulted will be used
  1812. -- for a text box initial value. Useful for being consulted inside the
  1813. -- translate and numeric callbacks.
  1814. local
  1815. str: STRING
  1816. do
  1817. str := iup_open.get_attribute(Current, "EDITVALUE")
  1818. Result := yesno_to_boolean(str)
  1819. end
  1820. is_cell_edited: BOOLEAN
  1821. -- To be used inside the Value Changed and Value Edit callbacks.
  1822. local
  1823. str: STRING
  1824. do
  1825. str := iup_open.get_attribute(Current, "CELL_EDITED")
  1826. Result := yesno_to_boolean(str)
  1827. end
  1828. -- Text Editing Attributes
  1829. set_caret (point: STRING)
  1830. -- Allows specifying and verifying the caret position of the text box in
  1831. -- edition mode.
  1832. --
  1833. -- Character position of the insertion point. Its format depends in
  1834. -- MULTILINE=true. The first position, lin or col, is "1".
  1835. --
  1836. -- For multiple lines: a string with the "lin,col" format, where lin and
  1837. -- col are integer numbers corresponding to the caret's position.
  1838. --
  1839. -- For single line: a string in the "col" format, where col is an integer
  1840. -- number corresponding to the caret's position.
  1841. --
  1842. -- When lin is greater than the number of lines, the caret is placed at
  1843. -- the last line. When col is greater than the number of characters in
  1844. -- the given line, the caret is placed after the last character of the
  1845. -- line.
  1846. --
  1847. -- If the caret is not visible the text is scrolled to make it visible.
  1848. --
  1849. -- See the Notes below if using UTF-8 strings in GTK.
  1850. do
  1851. iup_open.set_attribute(Current, "CARET", point)
  1852. end
  1853. get_caret: STRING
  1854. -- In Windows, if the element does not have the focus the returned value
  1855. -- is the position of the first character of the current selection. The
  1856. -- caret is only displayed if the element has the keyboard focus, but its
  1857. -- position can be changed even if not visible. When changed it will also
  1858. -- change the selection but the text will be scrolled only when it
  1859. -- receives the focus.
  1860. do
  1861. Result := iup_open.get_attribute(Current, "CARET")
  1862. end
  1863. insert_text (text: STRING)
  1864. -- Inserts a text at the caret position of the text box in edition mode.
  1865. do
  1866. iup_open.set_attribute(Current, "INSERT", text)
  1867. end
  1868. set_mask_at (mask: STRING; line, column: INTEGER)
  1869. -- Defines a mask that will filter interactive text
  1870. -- input. Use "REMOVE" to remove the mask.
  1871. --
  1872. -- Since the validation process is performed key by key when the user is
  1873. -- typing, an intermediate value cannot be typed if it does not follow
  1874. -- the mask rules.
  1875. --
  1876. -- If you set the VALUE attribute any text can be used. To set a value
  1877. -- that is validated by the current MASK use VALUEMASKED.
  1878. --
  1879. -- Pre-Defined Masks
  1880. --
  1881. -- Definition Value Description
  1882. -- IUP_MASK_INT "[+/-]?/d+" integer number
  1883. -- IUP_MASK_UINT "/d+" unsigned integer number
  1884. -- IUP_MASK_FLOAT "[+/-]?(/d+/.?/d*|/./d+)" floating point number
  1885. -- IUP_MASK_UFLOAT "(/d+/.?/d*|/./d+)" unsigned floating point number
  1886. -- IUP_MASK_EFLOAT "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?" floating
  1887. -- point number with exponential notation
  1888. -- IUP_MASK_FLOATCOMMA "[+/-]?(/d+/,?/d*|/,/d+)" floating point number
  1889. -- IUP_MASK_UFLOATCOMMA "(/d+/,?/d*|/,/d+)" unsigned floating point number
  1890. --
  1891. -- For more information see:
  1892. -- http://webserver2.tecgraf.puc-rio.br/iup/en/attrib/iup_mask.html
  1893. require
  1894. line > 0
  1895. column > 0
  1896. do
  1897. if mask.is_equal("REMOVE") then
  1898. iup_open.set_attribute_id2_null(Current, "MASK", line, column)
  1899. elseif mask_dictionary.has(mask) then
  1900. iup_open.set_attribute_id2(Current, "MASK", line, column, mask_dictionary.at(mask))
  1901. else
  1902. iup_open.set_attribute_id2(Current, "MASK", line, column, mask)
  1903. end
  1904. end
  1905. set_mask_case_insesitive_at (state: BOOLEAN; line, column: INTEGER)
  1906. -- If True, will turn the filter case insensitive. Default: False.
  1907. require
  1908. line > 0
  1909. column > 0
  1910. do
  1911. iup_open.set_attribute_id2(Current, "MASKCASEI", line, column, boolean_to_yesno(state))
  1912. end
  1913. set_mask_no_empty_at (state: BOOLEAN; line, column: INTEGER)
  1914. -- If True, value can NOT be Void or empty. Default: False (can be
  1915. -- empty or Void).
  1916. require
  1917. line > 0
  1918. column > 0
  1919. do
  1920. iup_open.set_attribute_id2(Current, "MASKNOEMPTY", line, column, boolean_to_yesno(state))
  1921. end
  1922. set_mask_decimal_symbol_at (value: STRING; line, column: INTEGER)
  1923. -- The decimal symbol for string/float conversion. Can be "." or ",".
  1924. -- Must be set before MASKFLOAT.
  1925. require
  1926. line > 0
  1927. column > 0
  1928. is_valid_symbol (value)
  1929. do
  1930. iup_open.set_attribute_id2(Current, "MASKDECIMALSYMBOL", line, column, value)
  1931. end
  1932. set_mask_integer_at (min, max, line, column: INTEGER)
  1933. -- Defines an integer mask with limits "min-max". It will replace MASK
  1934. -- using one of the pre-defined masks.
  1935. require
  1936. line > 0
  1937. column > 0
  1938. local
  1939. str: STRING
  1940. do
  1941. str := min.to_string
  1942. str.append_string(":")
  1943. str.append_string(max.to_string)
  1944. iup_open.set_attribute_id2(Current, "MASKINT", line, column, str)
  1945. end
  1946. set_mask_float_at (min, max: FLOAT; line, column: INTEGER)
  1947. -- Defines a floating point mask with limits "min:max". It will replace
  1948. -- MASK using one of the pre-defined masks.
  1949. require
  1950. line > 0
  1951. column > 0
  1952. local
  1953. str: STRING
  1954. do
  1955. str := min.to_string
  1956. str.append_string(":")
  1957. str.append_string(max.to_string)
  1958. iup_open.set_attribute_id2(Current, "MASKFLOAT", line, column, str)
  1959. end
  1960. set_mask_at_line (mask: STRING; line: INTEGER)
  1961. -- Defines a mask that will filter interactive text
  1962. -- input. Use "REMOVE" to remove the mask.
  1963. --
  1964. -- Since the validation process is performed key by key when the user is
  1965. -- typing, an intermediate value cannot be typed if it does not follow
  1966. -- the mask rules.
  1967. --
  1968. -- If you set the VALUE attribute any text can be used. To set a value
  1969. -- that is validated by the current MASK use VALUEMASKED.
  1970. --
  1971. -- Pre-Defined Masks
  1972. --
  1973. -- Definition Value Description
  1974. -- IUP_MASK_INT "[+/-]?/d+" integer number
  1975. -- IUP_MASK_UINT "/d+" unsigned integer number
  1976. -- IUP_MASK_FLOAT "[+/-]?(/d+/.?/d*|/./d+)" floating point number
  1977. -- IUP_MASK_UFLOAT "(/d+/.?/d*|/./d+)" unsigned floating point number
  1978. -- IUP_MASK_EFLOAT "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?" floating
  1979. -- point number with exponential notation
  1980. -- IUP_MASK_FLOATCOMMA "[+/-]?(/d+/,?/d*|/,/d+)" floating point number
  1981. -- IUP_MASK_UFLOATCOMMA "(/d+/,?/d*|/,/d+)" unsigned floating point number
  1982. --
  1983. -- For more information see:
  1984. -- http://webserver2.tecgraf.puc-rio.br/iup/en/attrib/iup_mask.html
  1985. require
  1986. line > 0
  1987. do
  1988. if mask.is_equal("REMOVE") then
  1989. iup_open.set_attribute_id2_null(Current, "MASK", line, -10)
  1990. elseif mask_dictionary.has(mask) then
  1991. iup_open.set_attribute_id2(Current, "MASK", line, -10, mask_dictionary.at(mask))
  1992. else
  1993. iup_open.set_attribute_id2(Current, "MASK", line, -10, mask)
  1994. end
  1995. end
  1996. set_mask_case_insesitive_at_line (state: BOOLEAN; line: INTEGER)
  1997. -- If True, will turn the filter case insensitive. Default: False.
  1998. require
  1999. line > 0
  2000. do
  2001. iup_open.set_attribute_id2(Current, "MASKCASEI", line, -10, boolean_to_yesno(state))
  2002. end
  2003. set_mask_no_empty_at_line (state: BOOLEAN; line: INTEGER)
  2004. -- If True, value can NOT be Void or empty. Default: False (can be
  2005. -- empty or Void).
  2006. require
  2007. line > 0
  2008. do
  2009. iup_open.set_attribute_id2(Current, "MASKNOEMPTY", line, -10, boolean_to_yesno(state))
  2010. end
  2011. set_mask_decimal_symbol_at_line (value: STRING; line: INTEGER)
  2012. -- The decimal symbol for string/float conversion. Can be "." or ",".
  2013. -- Must be set before MASKFLOAT.
  2014. require
  2015. line > 0
  2016. is_valid_symbol (value)
  2017. do
  2018. iup_open.set_attribute_id2(Current, "MASKDECIMALSYMBOL", line, -10, value)
  2019. end
  2020. set_mask_integer_at_line (min, max, line: INTEGER)
  2021. -- Defines an integer mask with limits "min-max". It will replace MASK
  2022. -- using one of the pre-defined masks.
  2023. require
  2024. line > 0
  2025. local
  2026. str: STRING
  2027. do
  2028. str := min.to_string
  2029. str.append_string(":")
  2030. str.append_string(max.to_string)
  2031. iup_open.set_attribute_id2(Current, "MASKINT", line, -10, str)
  2032. end
  2033. set_mask_float_at_line (min, max: FLOAT; line: INTEGER)
  2034. -- Defines a floating point mask with limits "min:max". It will replace
  2035. -- MASK using one of the pre-defined masks.
  2036. require
  2037. line > 0
  2038. local
  2039. str: STRING
  2040. do
  2041. str := min.to_string
  2042. str.append_string(":")
  2043. str.append_string(max.to_string)
  2044. iup_open.set_attribute_id2(Current, "MASKFLOAT", line, -10, str)
  2045. end
  2046. set_mask_at_column (mask: STRING; column: INTEGER)
  2047. -- Defines a mask that will filter interactive text
  2048. -- input. Use "REMOVE" to remove the mask.
  2049. --
  2050. -- Since the validation process is performed key by key when the user is
  2051. -- typing, an intermediate value cannot be typed if it does not follow
  2052. -- the mask rules.
  2053. --
  2054. -- If you set the VALUE attribute any text can be used. To set a value
  2055. -- that is validated by the current MASK use VALUEMASKED.
  2056. --
  2057. -- Pre-Defined Masks
  2058. --
  2059. -- Definition Value Description
  2060. -- IUP_MASK_INT "[+/-]?/d+" integer number
  2061. -- IUP_MASK_UINT "/d+" unsigned integer number
  2062. -- IUP_MASK_FLOAT "[+/-]?(/d+/.?/d*|/./d+)" floating point number
  2063. -- IUP_MASK_UFLOAT "(/d+/.?/d*|/./d+)" unsigned floating point number
  2064. -- IUP_MASK_EFLOAT "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?" floating
  2065. -- point number with exponential notation
  2066. -- IUP_MASK_FLOATCOMMA "[+/-]?(/d+/,?/d*|/,/d+)" floating point number
  2067. -- IUP_MASK_UFLOATCOMMA "(/d+/,?/d*|/,/d+)" unsigned floating point number
  2068. --
  2069. -- For more information see:
  2070. -- http://webserver2.tecgraf.puc-rio.br/iup/en/attrib/iup_mask.html
  2071. require
  2072. column > 0
  2073. do
  2074. if mask.is_equal("REMOVE") then
  2075. iup_open.set_attribute_id2_null(Current, "MASK", -10, column)
  2076. elseif mask_dictionary.has(mask) then
  2077. iup_open.set_attribute_id2(Current, "MASK", -10, column, mask_dictionary.at(mask))
  2078. else
  2079. iup_open.set_attribute_id2(Current, "MASK", -10, column, mask)
  2080. end
  2081. end
  2082. set_mask_case_insesitive_at_column (state: BOOLEAN; column: INTEGER)
  2083. -- If True, will turn the filter case insensitive. Default: False.
  2084. require
  2085. column > 0
  2086. do
  2087. iup_open.set_attribute_id2(Current, "MASKCASEI", -10, column, boolean_to_yesno(state))
  2088. end
  2089. set_mask_no_empty_at_column (state: BOOLEAN; column: INTEGER)
  2090. -- If True, value can NOT be Void or empty. Default: False (can be
  2091. -- empty or Void).
  2092. require
  2093. column > 0
  2094. do
  2095. iup_open.set_attribute_id2(Current, "MASKNOEMPTY", -10, column, boolean_to_yesno(state))
  2096. end
  2097. set_mask_decimal_symbol_at_column (value: STRING; column: INTEGER)
  2098. -- The decimal symbol for string/float conversion. Can be "." or ",".
  2099. -- Must be set before MASKFLOAT.
  2100. require
  2101. column > 0
  2102. is_valid_symbol (value)
  2103. do
  2104. iup_open.set_attribute_id2(Current, "MASKDECIMALSYMBOL", -10, column, value)
  2105. end
  2106. set_mask_integer_at_column (min, max, column: INTEGER)
  2107. -- Defines an integer mask with limits "min-max". It will replace MASK
  2108. -- using one of the pre-defined masks.
  2109. require
  2110. column > 0
  2111. local
  2112. str: STRING
  2113. do
  2114. str := min.to_string
  2115. str.append_string(":")
  2116. str.append_string(max.to_string)
  2117. iup_open.set_attribute_id2(Current, "MASKINT", -10, column, str)
  2118. end
  2119. set_mask_float_at_column (min, max: FLOAT; column: INTEGER)
  2120. -- Defines a floating point mask with limits "min:max". It will replace
  2121. -- MASK using one of the pre-defined masks.
  2122. require
  2123. column > 0
  2124. local
  2125. str: STRING
  2126. do
  2127. str := min.to_string
  2128. str.append_string(":")
  2129. str.append_string(max.to_string)
  2130. iup_open.set_attribute_id2(Current, "MASKFLOAT", -10, column, str)
  2131. end
  2132. set_multi_line (state: BOOLEAN)
  2133. -- Allows the edition of multiple lines. Use Shift+Enter to add lines.
  2134. -- Enter will end the editing.
  2135. do
  2136. iup_open.set_attribute(Current, "MULTILINE", boolean_to_yesno(state))
  2137. end
  2138. set_selection (value: STRING)
  2139. -- Allows specifying and verifying selection interval of the text box in
  2140. -- edition mode. The first position, lin or col, is "1".
  2141. --
  2142. -- For multiple lines: a string in the "lin1,col1:lin2,col2" format,
  2143. -- where lin1, col1, lin2 and col2 are integer numbers corresponding to
  2144. -- the selection's interval. col2 correspond to the character after the
  2145. -- last selected character.
  2146. --
  2147. -- For single line: a string in the "col1:col2" format, where col1 and
  2148. -- col2 are integer numbers corresponding to the selection's interval.
  2149. -- col2 correspond to the character after the last selected character.
  2150. --
  2151. -- In Windows, when changing the selection the caret position is also
  2152. -- changed.
  2153. --
  2154. -- See the Notes below if using UTF-8 strings in GTK.
  2155. do
  2156. iup_open.set_attribute(Current, "SELECTION", value)
  2157. end
  2158. select_all
  2159. -- Select all the text.
  2160. do
  2161. iup_open.set_attribute(Current, "SELECTION", "ALL")
  2162. end
  2163. deselect_all
  2164. -- Deselect.
  2165. do
  2166. iup_open.set_attribute(Current, "SELECTION", "NONE")
  2167. end
  2168. -- Canvas Attributes (inheritable)
  2169. set_border (state: BOOLEAN)
  2170. -- (creation only): Shows a border around the canvas. Default: "False".
  2171. do
  2172. Precursor (state)
  2173. end
  2174. set_scroll_bar (state: BOOLEAN)
  2175. -- (creation only): Associates a horizontal and/or vertical scrollbar to
  2176. -- the canvas. Default: "True". The secondary attributes are all non
  2177. -- inheritable.
  2178. do
  2179. Precursor (state)
  2180. end
  2181. -- Coordination to pos
  2182. convert_xy_to_pos (x, y: INTEGER): INTEGER
  2183. -- To convert (x,y) coordinates in the cell position, then use
  2184. -- "text_convert_pos_to_lin_col" to convert pos into (lin,col).
  2185. do
  2186. Result := iup_open.iup_convert_xy_to_pos (Current, x, y)
  2187. end
  2188. -- Callbacks
  2189. set_cb_action (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING])
  2190. -- Action generated when a keyboard event occurs.
  2191. --
  2192. -- ih: identifier of the element that activated the event.
  2193. --
  2194. -- key: Identifier of the typed key. Please refer to the Keyboard Codes
  2195. -- table for a list of possible values.
  2196. --
  2197. -- lin, col: Coordinates of the selected cell.
  2198. --
  2199. -- edition: 1 if the cell is in edition mode, and 0 if it is not.
  2200. --
  2201. -- value: When EDITMODE=False is the cell current value, but if the type
  2202. -- key is a valid character then contains a string with that character.
  2203. -- When EDITMODE=True depends on the editing field type. If a dropdown,
  2204. -- then it is an empty string (""). If a text, and the type key is a
  2205. -- valid character then it is the future value of the text field, if not
  2206. -- a valid character then it is the cell current value. Notice that this
  2207. -- value can be Void if the cell does not have a value and the key
  2208. -- pressed is not a character.
  2209. --
  2210. -- Returns: IUP_DEFAULT validates the key, IUP_IGNORE ignores the key,
  2211. -- IUP_CONTINUE forwards the key to IUPs conventional processing, or the
  2212. -- identifier of the key to be treated by the matrix.
  2213. local
  2214. operation: INTEGER
  2215. do
  2216. cb_action := act
  2217. if cb_action /= Void then
  2218. operation := 1
  2219. else
  2220. operation := 0
  2221. end
  2222. iup_open.set_callback (Current, "ACTION_CB", "NONEEDED", operation)
  2223. end
  2224. set_cb_click (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING])
  2225. -- Action generated when any mouse button is pressed over a cell. This
  2226. -- callback is always called after other callbacks. When
  2227. -- EDITHIDEONFOCUS=False and editing is on going the callback
  2228. -- EDITCLICK_CB with the same parameters will also be called right before
  2229. -- this one.
  2230. --
  2231. -- ih: identifier of the element that activated the event.
  2232. --
  2233. -- lin, col: Coordinates of the cell where the mouse button was pressed.
  2234. --
  2235. -- status: Status of the mouse buttons and some keyboard keys at the
  2236. -- moment the event is generated. The same macros used for BUTTON_CB can
  2237. -- be used for this status.
  2238. --
  2239. -- Returns: To avoid the display update return IUP_IGNORE.
  2240. local
  2241. operation: INTEGER
  2242. do
  2243. cb_click := act
  2244. if cb_click /= Void then
  2245. operation := 1
  2246. else
  2247. operation := 0
  2248. end
  2249. iup_open.set_callback (Current, "CLICK_CB", "NONEEDED", operation)
  2250. end
  2251. set_cb_column_resise (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER], STRING])
  2252. -- Action generated when a column is interactively resized:
  2253. --
  2254. -- ih: identifier of the element that activated the event.
  2255. -- col: Column that had its size changed.
  2256. local
  2257. operation: INTEGER
  2258. do
  2259. cb_colresize := act
  2260. if cb_colresize /= Void then
  2261. operation := 1
  2262. else
  2263. operation := 0
  2264. end
  2265. iup_open.set_callback (Current, "COLRESIZE_CB", "NONEEDED", operation)
  2266. end
  2267. set_cb_release (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING])
  2268. -- Action generated when any mouse button is released over a cell. This
  2269. -- callback is always called after other callbacks. When
  2270. -- EDITHIDEONFOCUS=False and editing is on going the callback
  2271. -- EDITRELEASE_CB with the same parameters will also be called right
  2272. -- before this one.
  2273. --
  2274. -- ih: identifier of the element that activated the event.
  2275. -- lin, col: Coordinates of the cell where the mouse button was pressed.
  2276. -- status: Status of the mouse buttons and some keyboard keys at the
  2277. -- moment the event is generated. The same macros used for
  2278. -- BUTTON_CB can be used for this status.
  2279. --
  2280. -- Returns: To avoid the display update return IUP_IGNORE.
  2281. local
  2282. operation: INTEGER
  2283. do
  2284. cb_release := act
  2285. if cb_release /= Void then
  2286. operation := 1
  2287. else
  2288. operation := 0
  2289. end
  2290. iup_open.set_callback (Current, "RELEASE_CB", "NONEEDED", operation)
  2291. end
  2292. set_cb_resize_matrix (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2293. -- Action generated after the element size has been updated but before
  2294. -- the cells have been actually refreshed.
  2295. --
  2296. -- ih: identifier of the element that activated the event.
  2297. -- width: the width of the internal element size in pixels not
  2298. -- considering the BORDER size (client size).
  2299. -- height: the height of the internal element size in pixels not
  2300. -- considering the BORDER size (client size).
  2301. local
  2302. operation: INTEGER
  2303. do
  2304. cb_resizematrix := act
  2305. if cb_resizematrix /= Void then
  2306. operation := 1
  2307. else
  2308. operation := 0
  2309. end
  2310. iup_open.set_callback (Current, "RESIZEMATRIX_CB", "NONEEDED", operation)
  2311. end
  2312. set_cb_toggle_value (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER], STRING])
  2313. -- Action generated when a toggle button is pressed.
  2314. --
  2315. -- ih: identifier of the element that activated the event.
  2316. -- lin, col: Coordinates of the cell where the mouse button was pressed.
  2317. -- status: Value of the toggle. Can be 1 or 0.
  2318. local
  2319. operation: INTEGER
  2320. do
  2321. cb_togglevalue := act
  2322. if cb_togglevalue /= Void then
  2323. operation := 1
  2324. else
  2325. operation := 0
  2326. end
  2327. iup_open.set_callback (Current, "TOGGLEVALUE_CB", "NONEEDED", operation)
  2328. end
  2329. set_cb_value_changed (act: FUNCTION[TUPLE[IUP_MATRIX], STRING])
  2330. -- Called after the value was interactively changed by the user or after
  2331. -- a group of values where programmatically changed in a single
  2332. -- operation. When it was interactively changed the temporary attribute
  2333. -- CELL_EDITED will be set to "True" during the callback
  2334. local
  2335. operation: INTEGER
  2336. do
  2337. cb_valuechanged := act
  2338. if cb_valuechanged /= Void then
  2339. operation := 1
  2340. else
  2341. operation := 0
  2342. end
  2343. iup_open.set_callback (Current, "VALUECHANGED_CB", "NONEEDED", operation)
  2344. end
  2345. set_cb_mouse_move (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2346. -- Action generated to notify the application that the mouse has moved
  2347. -- over the matrix. When EDITHIDEONFOCUS=False and editing is on going
  2348. -- the callback EDITMOUSEMOVE_CB with the same parameters will also be
  2349. -- called right before this one.
  2350. --
  2351. -- ih: identifier of the element that activated the event.
  2352. -- lin, col: Coordinates of the cell that the mouse cursor is
  2353. -- currently on.
  2354. local
  2355. operation: INTEGER
  2356. do
  2357. cb_mousemove := act
  2358. if cb_mousemove /= Void then
  2359. operation := 1
  2360. else
  2361. operation := 0
  2362. end
  2363. iup_open.set_callback (Current, "MOUSEMOVE_CB", "NONEEDED", operation)
  2364. end
  2365. set_cb_enter_item (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2366. -- Action generated when a matrix cell is selected, becoming the current
  2367. -- cell. Also called when matrix is getting focus. Also called when focus
  2368. -- is changed because lines or columns were added or removed.
  2369. --
  2370. -- ih: identifier of the element that activated the event.
  2371. -- lin, col: Coordinates of the selected cell.
  2372. local
  2373. operation: INTEGER
  2374. do
  2375. cb_enteritem := act
  2376. if cb_enteritem /= Void then
  2377. operation := 1
  2378. else
  2379. operation := 0
  2380. end
  2381. iup_open.set_callback (Current, "ENTERITEM_CB", "NONEEDED", operation)
  2382. end
  2383. set_cb_leave_item (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2384. -- Action generated when a cell is no longer the current cell. Also
  2385. -- called when the matrix is losing focus.
  2386. --
  2387. -- ih: identifier of the element that activated the event.
  2388. -- lin, col: Coordinates of the cell which is no longer the current cell.
  2389. --
  2390. -- Returns: IUP_IGNORE prevents the current cell from changing, but this
  2391. -- will not work when the matrix is losing focus. If you try to move to
  2392. -- beyond matrix borders the cell will lose focus and then get it again,
  2393. -- so leaveitem_cb and enteritem_cb will be called.
  2394. local
  2395. operation: INTEGER
  2396. do
  2397. cb_leaveitem := act
  2398. if cb_leaveitem /= Void then
  2399. operation := 1
  2400. else
  2401. operation := 0
  2402. end
  2403. iup_open.set_callback (Current, "LEAVEITEM_CB", "NONEEDED", operation)
  2404. end
  2405. set_cb_scroll_top (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2406. -- Action generated when the matrix is scrolled with the scrollbars or
  2407. -- with the keyboard. Can be used together with the ORIGIN and
  2408. -- ORIGINOFFSET attributes to synchronize the movement of two or more
  2409. -- matrices.
  2410. --
  2411. -- ih: identifier of the element that activated the event.
  2412. -- lin, col: Coordinates of the cell currently in the upper left corner
  2413. -- of the matrix.
  2414. local
  2415. operation: INTEGER
  2416. do
  2417. cb_scrolltop := act
  2418. if cb_scrolltop /= Void then
  2419. operation := 1
  2420. else
  2421. operation := 0
  2422. end
  2423. iup_open.set_callback (Current, "SCROLLTOP_CB", "NONEEDED", operation)
  2424. end
  2425. set_cb_background_color (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, POINTER, POINTER, POINTER], STRING])
  2426. -- Action generated to retrieve the background color of a cell when it
  2427. -- needs to be redrawn.
  2428. --
  2429. -- ih: identifier of the element that activated the event.
  2430. -- lin, col: Coordinates of the cell.
  2431. -- red, green, blue: the cell background color.
  2432. --
  2433. -- Returns: If IUP_IGNORE, the values are ignored and the attribute
  2434. -- defined background color will be used. If returns IUP_DEFAULT the
  2435. -- returned values will be used as the background color.
  2436. local
  2437. operation: INTEGER
  2438. do
  2439. cb_bgcolor := act
  2440. if cb_bgcolor /= Void then
  2441. operation := 1
  2442. else
  2443. operation := 0
  2444. end
  2445. iup_open.set_callback (Current, "BGCOLOR_CB", "NONEEDED", operation)
  2446. end
  2447. set_cb_foreground_color (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, POINTER, POINTER, POINTER], STRING])
  2448. -- Action generated to retrieve the foreground color of a cell when it
  2449. -- needs to be redrawn.
  2450. --
  2451. -- ih: identifier of the element that activated the event.
  2452. -- lin, col: Coordinates of the cell.
  2453. -- red, green, blue: the cell foreground color.
  2454. --
  2455. -- Returns: If IUP_IGNORE, the values are ignored and the attribute
  2456. -- defined foreground color will be used. If returns IUP_DEFAULT the
  2457. -- returned values will be used as the foreground color.
  2458. local
  2459. operation: INTEGER
  2460. do
  2461. cb_fgcolor := act
  2462. if cb_fgcolor /= Void then
  2463. operation := 1
  2464. else
  2465. operation := 0
  2466. end
  2467. iup_open.set_callback (Current, "FGCOLOR_CB", "NONEEDED", operation)
  2468. end
  2469. set_cb_font (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2470. -- Action generated to retrieve the font of a cell. Called both for
  2471. -- common cells and for line and column titles.
  2472. --
  2473. -- ih: identifier of the element that activated the event.
  2474. -- lin, col: Coordinates of the cell.
  2475. --
  2476. -- Returns: Must return a font or NULL to use the the attribute defined
  2477. -- font.
  2478. local
  2479. operation: INTEGER
  2480. do
  2481. cb_font := act
  2482. if cb_font /= Void then
  2483. operation := 1
  2484. else
  2485. operation := 0
  2486. end
  2487. iup_open.set_callback (Current, "FONT_CB", "NONEEDED", operation)
  2488. end
  2489. set_cb_type (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2490. -- Action generated to retrieve the type of a cell value. Called both for
  2491. -- common cells and for line and column titles.
  2492. --
  2493. -- ih: identifier of the element that activated the event.
  2494. -- lin, col: Coordinates of the cell.
  2495. --
  2496. -- Returns: Must return "TEXT", "COLOR", "FILL" or "IMAGE".
  2497. local
  2498. operation: INTEGER
  2499. do
  2500. cb_type := act
  2501. if cb_type /= Void then
  2502. operation := 1
  2503. else
  2504. operation := 0
  2505. end
  2506. iup_open.set_callback (Current, "TYPE_CB", "NONEEDED", operation)
  2507. end
  2508. set_cb_draw (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, CD_IUP], STRING])
  2509. -- Called when a specific cell needs to be redrawn.
  2510. --
  2511. -- ih: identifier of the element that activated the event.
  2512. -- line, column: the grid position inside the control that is being
  2513. -- redrawn, in grid coordinates.
  2514. -- xmin, xmax, ymin, ymax: the raster bounding box of the redrawn cells,
  2515. -- where the application can use CD functions to draw anything. If
  2516. -- the attribute IUP_CLIPPED is set (the default), all CD graphical
  2517. -- primitives is clipped to the bounding region.
  2518. -- canvas: internal canvas CD used to draw the cells.
  2519. --
  2520. -- Returns: "IUP_DEFAULT", "IUP_CONTINUE" or "IUP_IGNORE"
  2521. local
  2522. operation: INTEGER
  2523. do
  2524. cb_draw := act
  2525. if cb_draw /= Void then
  2526. operation := 1
  2527. else
  2528. operation := 0
  2529. end
  2530. iup_open.set_callback (Current, "DRAW_CB", "NONEEDED", operation)
  2531. end
  2532. set_cb_drop_check (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2533. -- Action generated before the current cell is redrawn to determine if a
  2534. -- dropdown/popup menu feedback or a toggle should be shown. If this
  2535. -- action is not registered, no feedback will be shown. If the callback
  2536. -- is defined and return IUP_DEFAULT for a cell, to show the
  2537. -- dropdown/popup menu the user can simply do a single click in the drop
  2538. -- feedback area of that cell.
  2539. --
  2540. -- ih: identifier of the element that activated the event.
  2541. -- lin, col: Coordinates of the cell.
  2542. --
  2543. -- Returns: IUP_DEFAULT will show a drop feedback, IUP_CONTINUE will show
  2544. -- and enable the toggle button, or IUP_IGNORE to draw nothing.
  2545. local
  2546. operation: INTEGER
  2547. do
  2548. cb_dropcheck := act
  2549. if cb_dropcheck /= Void then
  2550. operation := 1
  2551. else
  2552. operation := 0
  2553. end
  2554. iup_open.set_callback (Current, "DROPCHECK_CB", "NONEEDED", operation)
  2555. end
  2556. set_cb_translate_value (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING])
  2557. -- Action generated to translate the value of a cell during display and
  2558. -- size computation. Called both for common cells and for line and column
  2559. -- titles.
  2560. --
  2561. -- ih: identifier of the element that activated the event.
  2562. -- lin, col: Coordinates of the cell.
  2563. -- value: original cell value
  2564. --
  2565. -- Returns: the string to be drawn.
  2566. local
  2567. operation: INTEGER
  2568. do
  2569. cb_translatevalue := act
  2570. if cb_translatevalue /= Void then
  2571. operation := 1
  2572. else
  2573. operation := 0
  2574. end
  2575. iup_open.set_callback (Current, "TRANSLATEVALUE_CB", "NONEEDED", operation)
  2576. end
  2577. set_cb_drop (act: FUNCTION[TUPLE[IUP_MATRIX, IUP_DROP, INTEGER, INTEGER], STRING])
  2578. -- Action generated before the current cell enters edition mode to
  2579. -- determine if a text field or a dropdown list will be shown. It is
  2580. -- called after EDITION_CB. If this action is not registered, a text field
  2581. -- will be shown. Its return determines what type of element will be used
  2582. -- in the edition mode. If the selected type is a dropdown, the values
  2583. -- appearing in the dropdown must be fulfilled in this callback, just like
  2584. -- elements are added to any list (the drop parameter is the handle of the
  2585. -- dropdown list to be shown). You should also set the lists current value
  2586. -- ("VALUE"), the default is always "1". The previously cell value can be
  2587. -- verified from the given drop Ihandle via the "PREVIOUSVALUE"
  2588. -- attribute.
  2589. --
  2590. -- ih: identifier of the element that activated the event.
  2591. -- drop: Identifier of the dropdown list which will be shown to the user.
  2592. -- lin, col: Coordinates of the current cell.
  2593. --
  2594. -- Returns: IUP_IGNORE to show a text-edition field, or IUP_DEFAULT to
  2595. -- show a dropdown field.
  2596. local
  2597. operation: INTEGER
  2598. do
  2599. cb_drop := act
  2600. if cb_drop /= Void then
  2601. operation := 1
  2602. else
  2603. operation := 0
  2604. end
  2605. iup_open.set_callback (Current, "DROP_CB", "NONEEDED", operation)
  2606. end
  2607. set_cb_menu_drop (act: FUNCTION[TUPLE[IUP_MATRIX, IUP_DROP, INTEGER, INTEGER], STRING])
  2608. -- Action generated before the current cell enters edition mode to
  2609. -- determine if a popup menu will be shown instead of a text field or a
  2610. -- dropdown. If this action is registered and retunr IUP_DEFAULT the
  2611. -- DROP_CB callback is not called, and the popup menu is shown. Like
  2612. -- DROP_CB, it is called after EDITION_CB. The values appearing as menu
  2613. -- items in the popup menu must be fulfilled in this callback, like
  2614. -- elements are added to a list (the drop parameter is the handle of the
  2615. -- popup menu to be shown, but the actual items will be added later by
  2616. -- the internal processing). You could also set the "VALUE" attribute
  2617. -- that will add a mark to the menu item with the same number. If IMAGEid
  2618. -- is set then an IMAGE attribute will be set at the correspondent menu
  2619. -- item. The previously cell value can be verified from the given drop
  2620. -- Ihandle via the "PREVIOUSVALUE" attribute.
  2621. --
  2622. -- ih: identifier of the element that activated the event.
  2623. -- drop: Identifier of the popup menu which will be shown to the user.
  2624. -- lin, col: Coordinates of the current cell.
  2625. --
  2626. -- Returns: IUP_IGNORE to not show the menu for the given cell, DROP_CB
  2627. -- will then be called.
  2628. local
  2629. operation: INTEGER
  2630. do
  2631. cb_menudrop := act
  2632. if cb_menudrop /= Void then
  2633. operation := 1
  2634. else
  2635. operation := 0
  2636. end
  2637. iup_open.set_callback (Current, "MENUDROP_CB", "NONEEDED", operation)
  2638. end
  2639. set_cb_drop_select (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, IUP_DROP, STRING, INTEGER, INTEGER], STRING])
  2640. -- Action generated when an element in the dropdown list or the popup
  2641. -- menu is selected. For the dropdown, if returns IUP_CONTINUE the value
  2642. -- is accepted as a new value and the matrix leaves edition mode, else
  2643. -- the item is selected and editing remains. For the popup menu the
  2644. -- returned value is ignored.
  2645. --
  2646. -- ih: identifier of the element that activated the event.
  2647. -- lin, col: Coordinates of the current cell.
  2648. -- drop: Identifier of the dropdown list or the popup menu shown to
  2649. -- the user.
  2650. -- t: Text of the item whose state was changed.
  2651. -- i: Number of the item whose state was changed.
  2652. -- v: Indicates if item was selected or unselected (1 or 0).
  2653. -- Always 1 for the popup menu.
  2654. local
  2655. operation: INTEGER
  2656. do
  2657. cb_dropselect := act
  2658. if cb_dropselect /= Void then
  2659. operation := 1
  2660. else
  2661. operation := 0
  2662. end
  2663. iup_open.set_callback (Current, "DROPSELECT_CB", "NONEEDED", operation)
  2664. end
  2665. set_cb_edition (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER], STRING])
  2666. -- Action generated when the current cell enters or leaves the edition
  2667. -- mode. Not called if READONLY=True.
  2668. --
  2669. -- ih: identifier of the element that activated the event.
  2670. -- lin, col: Coordinates of the current cell.
  2671. -- mode: 1 if the cell has entered the edition mode, or 0 if the cell
  2672. -- has left the edition mode.
  2673. -- update: used when mode=0 to identify if the value will be updated
  2674. -- when the callback returns with IUP_DEFAULT. (since 3.0)
  2675. --
  2676. -- Returns: can be IUP_DEFAULT, IUP_IGNORE or IUP_CONTINUE.
  2677. --
  2678. -- If the callback does not exists the cell can always be edited and the
  2679. -- new value is always accepted.
  2680. --
  2681. -- When editing is started, mode=1 and update=0. Editing is allowed if
  2682. -- the callback returns IUP_DEFAULT, so to make the cell read-only return
  2683. -- IUP_IGNORE.
  2684. --
  2685. -- When editing ends, mode=0 and update can be 0 or 1. The new value is
  2686. -- accepted only if the callback returns IUP_DEFAULT. The VALUE attribute
  2687. -- when consulted inside the callback returns the new value that will be
  2688. -- updated to the cell. update=0 only when the user cancel the editing by
  2689. -- pressing the Esc key. If the callback returns IUP_CONTINUE the edit
  2690. -- mode is ended and the new value will not be updated, so the
  2691. -- application can set a different value during the callback (useful to
  2692. -- format the new value). If the callback returns IUP_IGNORE the editing
  2693. -- is not ended, with several exceptions: the Esc key was used; the
  2694. -- matrix size, scroll or visibility was changed during edition mode; a
  2695. -- click in another cell; or the edit control loses its focus.
  2696. --
  2697. -- This callback is also called when the user press Del to clear the cell
  2698. -- contents or other multiple cell editing. The callback will simply
  2699. -- validate the operation for each cell been cleared by checking if the
  2700. -- matrix is read-only or if the cell is read-only. In this situation it
  2701. -- is called with mode=1 and update=1. When in normal mode (not callback
  2702. -- mode) the new value can not be refused, but you can use the
  2703. -- VALUE_EDIT_CB to reset a new value or use the VALUECHANGED_CB to check
  2704. -- all the new values after they where changed.
  2705. local
  2706. operation: INTEGER
  2707. do
  2708. cb_edition := act
  2709. if cb_edition /= Void then
  2710. operation := 1
  2711. else
  2712. operation := 0
  2713. end
  2714. iup_open.set_callback (Current, "EDITION_CB", "NONEEDED", operation)
  2715. end
  2716. set_cb_value (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING])
  2717. -- Action generated to retrieve the value of a cell. Called both for
  2718. -- common cells and for line and column titles.
  2719. --
  2720. -- ih: identifier of the element that activated the event.
  2721. -- lin, col: Coordinates of the cell.
  2722. --
  2723. -- Returns: the string to be drawn.
  2724. --
  2725. -- IMPORTANT: The existence of this callback defines the callback
  2726. -- operation mode of the matrix when it is mapped.
  2727. local
  2728. operation: INTEGER
  2729. do
  2730. cb_value := act
  2731. if cb_value /= Void then
  2732. operation := 1
  2733. else
  2734. operation := 0
  2735. end
  2736. iup_open.set_callback (Current, "VALUE_CB", "NONEEDED", operation)
  2737. end
  2738. set_cb_value_edit (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING])
  2739. -- Action generated to notify the application that the value of a cell
  2740. -- was changed. Never called when READONLY=YES. This callback is usually
  2741. -- set in callback mode, but also works in normal mode. When in normal
  2742. -- mode, it is called after the new value has been internally stored, so
  2743. -- to refuse the new value simply reset the cell to the desired value.
  2744. -- When it was interactively changed the temporary attribute CELL_EDITED
  2745. -- will be set to Yes during the callback.
  2746. --
  2747. -- ih: identifier of the element that activated the event.
  2748. -- lin, col: Coordinates of the cell.
  2749. -- newval: String containing the new cell value
  2750. --
  2751. -- IMPORTANT: if VALUE_CB is defined and VALUE_EDIT_CB is not defined
  2752. -- when the matrix is mapped it will be read-only.
  2753. local
  2754. operation: INTEGER
  2755. do
  2756. cb_value_edit := act
  2757. if cb_value_edit /= Void then
  2758. operation := 1
  2759. else
  2760. operation := 0
  2761. end
  2762. iup_open.set_callback (Current, "VALUE_EDIT_CB", "NONEEDED", operation)
  2763. end
  2764. set_cb_mark (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], INTEGER])
  2765. -- Action generated to retrieve the selection state of a cell. Called
  2766. -- only for common cells, only when MARKMODE=CELL and only in callback
  2767. -- mode.
  2768. --
  2769. -- ih: identifier of the element that activated the event.
  2770. -- lin, col: Coordinates of the cell.
  2771. --
  2772. -- Returns: the selection state (marked=1, not marked 0). If not defined
  2773. -- the attribute "MARKL:C" will be returned.
  2774. local
  2775. operation: INTEGER
  2776. do
  2777. cb_mark := act
  2778. if cb_mark /= Void then
  2779. operation := 1
  2780. else
  2781. operation := 0
  2782. end
  2783. iup_open.set_callback (Current, "MARK_CB", "NONEEDED", operation)
  2784. end
  2785. set_cb_mark_edit (act: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER], STRING])
  2786. -- Action generated to notify the application that the selection state of
  2787. -- a cell was changed. Since it is a notification, it cannot refuse the
  2788. -- mark modification. Called only for common cells, only when
  2789. -- MARKMODE=CELL and only in callback mode.
  2790. --
  2791. -- ih: identifier of the element that activated the event.
  2792. -- lin, col: Coordinates of the cell.
  2793. -- marked: selection state (marked=1, not marked 0).
  2794. --
  2795. -- If not defined the attribute "MARKL:C" will be updated. So if you
  2796. -- define the MARKEDIT_CB the "MARKL:C" will NOT be updated and the
  2797. -- callback MARK_CB must return the selection state of the cell. If you
  2798. -- do not want to implement the MARK_CB callback then set the "MARKL:C"
  2799. -- attribute inside the MARKEDIT_CB callback.
  2800. local
  2801. operation: INTEGER
  2802. do
  2803. cb_markedit := act
  2804. if cb_markedit /= Void then
  2805. operation := 1
  2806. else
  2807. operation := 0
  2808. end
  2809. iup_open.set_callback (Current, "MARKEDIT_CB", "NONEEDED", operation)
  2810. end
  2811. feature {IUP}
  2812. -- Matrix
  2813. execute_action_fniiiis (key, lin, col, edition: INTEGER; value: STRING): STRING
  2814. do
  2815. Result := cb_action.item([Current, key, lin, col, edition, value])
  2816. end
  2817. execute_click_fniis (lin, col: INTEGER; status: STRING): STRING
  2818. do
  2819. Result := cb_click.item([Current, lin, col, status])
  2820. end
  2821. execute_colresize (col: INTEGER): STRING
  2822. do
  2823. Result := cb_colresize.item([Current, col])
  2824. end
  2825. execute_release (lin, col: INTEGER; status: STRING): STRING
  2826. do
  2827. Result := cb_release.item([Current, lin, col, status])
  2828. end
  2829. execute_resizematrix (width, height: INTEGER): STRING
  2830. do
  2831. Result := cb_resizematrix.item([Current, width, height])
  2832. end
  2833. execute_togglevalue_fniii (lin, col, status: INTEGER): STRING
  2834. do
  2835. Result := cb_togglevalue.item([Current, lin, col, status])
  2836. end
  2837. execute_valuechanged: STRING
  2838. do
  2839. Result := cb_valuechanged.item([Current])
  2840. end
  2841. execute_mousemove (lin, col: INTEGER): STRING
  2842. do
  2843. Result := cb_mousemove.item([Current, lin, col])
  2844. end
  2845. execute_enteritem (lin, col: INTEGER): STRING
  2846. do
  2847. Result := cb_enteritem.item([Current, lin, col])
  2848. end
  2849. execute_leaveitem (lin, col: INTEGER): STRING
  2850. do
  2851. Result := cb_leaveitem.item([Current, lin, col])
  2852. end
  2853. execute_scrolltop (lin, col: INTEGER): STRING
  2854. do
  2855. Result := cb_scrolltop.item([Current, lin, col])
  2856. end
  2857. execute_bgcolor (lin, col: INTEGER; red, green, blue: POINTER): STRING
  2858. do
  2859. Result := cb_bgcolor.item([Current, lin, col, red, green, blue])
  2860. end
  2861. execute_fgcolor (lin, col: INTEGER; red, green, blue: POINTER): STRING
  2862. do
  2863. Result := cb_fgcolor.item([Current, lin, col, red, green, blue])
  2864. end
  2865. execute_font (lin, col: INTEGER): STRING
  2866. do
  2867. Result := cb_font.item([Current, lin, col])
  2868. end
  2869. execute_type (lin, col: INTEGER): STRING
  2870. do
  2871. Result := cb_type.item([Current, lin, col])
  2872. end
  2873. execute_draw (line, column, xmin, xmax, ymin, ymax: INTEGER; canvas: POINTER): STRING
  2874. do
  2875. Result := cb_draw.item([Current, line, column, xmin, xmax, ymin, ymax, internal_cd(canvas)])
  2876. end
  2877. execute_dropcheck (lin, col: INTEGER): STRING
  2878. do
  2879. Result := cb_dropcheck.item([Current, lin, col])
  2880. end
  2881. execute_translatevalue (lin, col: INTEGER; value: STRING): STRING
  2882. do
  2883. Result := cb_translatevalue.item([Current, lin, col, value])
  2884. end
  2885. execute_drop (drop: IUP_DROP; lin, col: INTEGER): STRING
  2886. do
  2887. Result := cb_drop.item([Current, drop, lin, col])
  2888. end
  2889. execute_menudrop (drop: IUP_DROP; lin, col: INTEGER): STRING
  2890. do
  2891. Result := cb_menudrop.item([Current, drop, lin, col])
  2892. end
  2893. execute_dropselect (lin, col: INTEGER; drop: IUP_DROP; t: STRING; i, v: INTEGER): STRING
  2894. do
  2895. Result := cb_dropselect.item([Current, lin, col, drop, t, i, v])
  2896. end
  2897. execute_edition (lin, col, mode, update: INTEGER): STRING
  2898. do
  2899. Result := cb_edition.item([Current, lin, col, mode, update])
  2900. end
  2901. execute_value (lin, col: INTEGER): STRING
  2902. do
  2903. Result := cb_value.item([Current, lin, col])
  2904. end
  2905. execute_value_edit (lin, col: INTEGER; newval: STRING): STRING
  2906. do
  2907. Result := cb_value_edit.item([Current, lin, col, newval])
  2908. end
  2909. execute_mark (lin, col: INTEGER): INTEGER
  2910. do
  2911. Result := cb_mark.item([Current, lin, col])
  2912. end
  2913. execute_markedit (lin, col, marked: INTEGER): STRING
  2914. do
  2915. Result := cb_markedit.item([Current, lin, col, marked])
  2916. end
  2917. feature {}
  2918. -- For callbacks
  2919. cb_action: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER, STRING], STRING]
  2920. cb_click: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING]
  2921. cb_colresize: FUNCTION[TUPLE[IUP_MATRIX, INTEGER], STRING]
  2922. cb_release: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING]
  2923. cb_resizematrix: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2924. cb_togglevalue: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER], STRING]
  2925. cb_valuechanged: FUNCTION[TUPLE[IUP_MATRIX], STRING]
  2926. cb_mousemove: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2927. cb_enteritem: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2928. cb_leaveitem: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2929. cb_scrolltop: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2930. cb_bgcolor: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, POINTER, POINTER, POINTER], STRING]
  2931. cb_fgcolor: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, POINTER, POINTER, POINTER], STRING]
  2932. cb_font: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2933. cb_type: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2934. cb_draw: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, CD_IUP], STRING]
  2935. cb_dropcheck: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2936. cb_translatevalue: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING]
  2937. cb_drop: FUNCTION[TUPLE[IUP_MATRIX, IUP_DROP, INTEGER, INTEGER], STRING]
  2938. cb_menudrop: FUNCTION[TUPLE[IUP_MATRIX, IUP_DROP, INTEGER, INTEGER], STRING]
  2939. cb_dropselect: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, IUP_DROP, STRING, INTEGER, INTEGER], STRING]
  2940. cb_edition: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER, INTEGER], STRING]
  2941. cb_value: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], STRING]
  2942. cb_value_edit: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, STRING], STRING]
  2943. cb_mark: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER], INTEGER]
  2944. cb_markedit: FUNCTION[TUPLE[IUP_MATRIX, INTEGER, INTEGER, INTEGER], STRING]
  2945. -- Mask dictionary
  2946. mask_dictionary: DICTIONARY[STRING, STRING]
  2947. -- Validations
  2948. is_valid_lin_align (value: STRING): BOOLEAN
  2949. do
  2950. if value.is_equal("ATOP") or
  2951. value.is_equal("ACENTER") or
  2952. value.is_equal("ABOTTOM") then
  2953. Result := True
  2954. else
  2955. Result := False
  2956. end
  2957. end
  2958. is_valid_col_align (value: STRING): BOOLEAN
  2959. do
  2960. if value.is_equal("ALEFT") or
  2961. value.is_equal("ACENTER") or
  2962. value.is_equal("ARIGHT") then
  2963. Result := True
  2964. else
  2965. Result := False
  2966. end
  2967. end
  2968. is_valid_type_cell (value: STRING): BOOLEAN
  2969. do
  2970. if value.is_equal("TEXT") or
  2971. value.is_equal("COLOR") or
  2972. value.is_equal("FILL") or
  2973. value.is_equal("IMAGE") then
  2974. Result := True
  2975. else
  2976. Result := False
  2977. end
  2978. end
  2979. is_valid_sort_sign (value: STRING): BOOLEAN
  2980. do
  2981. if value.is_equal("UP") or
  2982. value.is_equal("DOWN") or
  2983. value.is_equal("NO") then
  2984. Result := True
  2985. else
  2986. Result := False
  2987. end
  2988. end
  2989. is_valid_symbol (value: STRING): BOOLEAN
  2990. do
  2991. if value.is_equal(".") or
  2992. value.is_equal(",") then
  2993. Result := True
  2994. else
  2995. Result := False
  2996. end
  2997. end
  2998. is_valid_edit_next (value: STRING): BOOLEAN
  2999. do
  3000. if value.is_equal("LIN") or
  3001. value.is_equal("LINCR") or
  3002. value.is_equal("COL") or
  3003. value.is_equal("COLCR") or
  3004. value.is_equal("NONE") then
  3005. Result := True
  3006. else
  3007. Result := False
  3008. end
  3009. end
  3010. -- Converts
  3011. string_to_boolean(value: STRING): BOOLEAN
  3012. do
  3013. if value.is_equal("0") then
  3014. Result := False
  3015. else
  3016. Result := True
  3017. end
  3018. end
  3019. array_to_marks (array: FAST_ARRAY[BOOLEAN]): STRING
  3020. local
  3021. x: INTEGER
  3022. s: STRING
  3023. do
  3024. create s.with_capacity(array.count)
  3025. from
  3026. x := 0
  3027. until
  3028. x = array.count
  3029. loop
  3030. s.append_character(array.item(x).to_character)
  3031. x := x + 1
  3032. end
  3033. Result := s
  3034. end
  3035. array2_to_marks (array: FAST_ARRAY2[BOOLEAN]): STRING
  3036. local
  3037. x, y: INTEGER
  3038. s: STRING
  3039. do
  3040. create s.with_capacity(array.count1*array.count2)
  3041. from
  3042. x := 0
  3043. until
  3044. x = array.count2
  3045. loop
  3046. from
  3047. y := 0
  3048. until
  3049. y = array.count1
  3050. loop
  3051. s.append_character(array.item(x, y).to_character)
  3052. y := y + 1
  3053. end
  3054. x := x + 1
  3055. end
  3056. Result := s
  3057. end
  3058. marks_to_array(values: STRING; size: INTEGER): FAST_ARRAY[BOOLEAN]
  3059. local
  3060. i: INTEGER
  3061. element: BOOLEAN
  3062. iterator: ITERATOR[CHARACTER]
  3063. mtx: FAST_ARRAY[BOOLEAN]
  3064. do
  3065. iterator := values.new_iterator
  3066. create mtx.make(size)
  3067. from
  3068. i := 0
  3069. iterator.start
  3070. until
  3071. iterator.is_off
  3072. loop
  3073. if iterator.item.is_equal('1') then
  3074. element := True
  3075. else
  3076. element := False
  3077. end
  3078. mtx.put(element, i)
  3079. i := i + 1
  3080. iterator.next
  3081. end
  3082. Result := mtx
  3083. end
  3084. marks_to_array2(values: STRING): FAST_ARRAY2[BOOLEAN]
  3085. local
  3086. i: INTEGER
  3087. element: BOOLEAN
  3088. iterator: ITERATOR[CHARACTER]
  3089. mtx: FAST_ARRAY2[BOOLEAN]
  3090. do
  3091. iterator := values.new_iterator
  3092. create mtx.make(get_number_of_lines, get_number_of_columns)
  3093. from
  3094. i := 0
  3095. iterator.start
  3096. until
  3097. iterator.is_off
  3098. loop
  3099. if iterator.item.is_equal('1') then
  3100. element := True
  3101. else
  3102. element := False
  3103. end
  3104. mtx.put(element, i//mtx.count2, i\\mtx.count1)
  3105. i := i + 1
  3106. iterator.next
  3107. end
  3108. Result := mtx
  3109. end
  3110. components_of_alignment (value: STRING): TUPLE[STRING, STRING]
  3111. local
  3112. i, c: INTEGER
  3113. line, col: STRING
  3114. tup: TUPLE[STRING, STRING]
  3115. do
  3116. if value.has(':') then
  3117. i := value.index_of(':', 1)
  3118. c := value.count
  3119. if not i.is_equal(1) then
  3120. line := value.substring(1, i - 1)
  3121. else
  3122. line := "0"
  3123. end
  3124. if not i.is_equal(c) then
  3125. col := value.substring(i + 1, c)
  3126. else
  3127. col := "0"
  3128. end
  3129. tup := [line, col]
  3130. Result := tup
  3131. else
  3132. io.put_string("Unable to get the components %N")
  3133. end
  3134. end
  3135. -- Internals
  3136. int_matrix(action: POINTER): POINTER
  3137. external "plug_in"
  3138. alias "{
  3139. location: "${sys}/plugins"
  3140. module_name: "iup"
  3141. feature_name: "IupMatrix"
  3142. }"
  3143. end
  3144. create_mask_dictionary
  3145. do
  3146. mask_dictionary := {HASHED_DICTIONARY[STRING, STRING] <<
  3147. "[+/-]?(/d+/.?/d*|/./d+)", "IUP_MASK_FLOAT";
  3148. "(/d+/.?/d*|/./d+)", "IUP_MASK_UFLOAT";
  3149. "[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?", "IUP_MASK_EFLOAT";
  3150. "[+/-]?(/d+/,?/d*|/,/d+)", "IUP_MASK_FLOATCOMMA";
  3151. "(/d+/,?/d*|/,/d+)", "IUP_MASK_UFLOATCOMMA";
  3152. "[+/-]?/d+", "IUP_MASK_INT";
  3153. "/d+", "IUP_MASK_UINT" >> }
  3154. end
  3155. end
  3156. -- The MIT License (MIT)
  3157. -- Copyright (c) 2016, 2017, 2018, 2019, 2022 by German A. Arias
  3158. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  3159. -- of this software and associated documentation files (the "Software"), to deal
  3160. -- in the Software without restriction, including without limitation the rights
  3161. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3162. -- copies of the Software, and to permit persons to whom the Software is
  3163. -- furnished to do so, subject to the following conditions:
  3164. --
  3165. -- The above copyright notice and this permission notice shall be included in
  3166. -- all copies or substantial portions of the Software.
  3167. --
  3168. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3169. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3170. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3171. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3172. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3173. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  3174. -- SOFTWARE.