iup_matrix.e 113 KB

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