iup_matrix.e 109 KB

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