@@ -135,6 +135,22 @@ appear at the right to enable the removal of that element, or the addition of a
135135
136136property readOnly get mReadOnly set setReadOnly
137137
138+ /*
139+ Syntax: set the arrayStyle of <widget> to {true|false}
140+ Syntax: get the arrayStyle of <widget>
141+
142+ Summary: Whether the tree view should display its contents in array style or as a standard tree view.
143+
144+ Description:
145+ The <arrayStyle> property controls whether the keys of the <arrayData> of the widget are displayed with
146+ square brackets around them or not.
147+
148+ References: arrayData (property)
149+ */
150+
151+ property arrayStyle get mArrayStyle set setArrayStyle
152+
153+
138154// The unmodified array data
139155private variable mData as Array
140156// A flat list representing the array items to be displayed
@@ -180,6 +196,7 @@ private variable mIconRect as Rectangle
180196private variable mIconWidth as Real
181197
182198private variable mReadOnly as Boolean
199+ private variable mArrayStyle as Boolean
183200
184201constant kMaxKeyDisplayChars is 50
185202constant kMaxValueDisplayChars is 200
@@ -224,6 +241,7 @@ public handler OnCreate() returns nothing
224241 initialiseScrollbar()
225242
226243 put false into mReadOnly
244+ put false into mArrayStyle
227245 put true into mRecalculate
228246
229247 put the empty array into mFoldState
@@ -239,13 +257,18 @@ public handler OnSave(out rProperties as Array)
239257 put mData into rProperties["array"]
240258 put mSelectedRowColor into rProperties["selected row color"]
241259 put mReadOnly into rProperties["read only"]
260+ put mArrayStyle into rProperties["array style"]
242261 return rProperties
243262end handler
244263
245264public handler OnLoad(in pProperties as Array)
246265 put pProperties["array"] into mData
247266 put pProperties["selected row color"] into mSelectedRowColor
248267 put pProperties["read only"] into mReadOnly
268+
269+ if ["array style"] is in the keys of pProperties then
270+ put pProperties["array style"] into mArrayStyle
271+ end if
249272end handler
250273
251274public handler OnPaint() returns nothing
@@ -378,10 +401,14 @@ private handler paintDataItem(in pDataItem as Array, in pTop as Real, in pRow as
378401 put (char 1 to kMaxKeyDisplayChars of pDataItem["key"]) & "..." into tKeyDisplay
379402 end if
380403
381- fill text "[" & tKeyDisplay & "]" at left of rectangle [tLeft, pTop, mViewWidth - 3 * mMargin - 2 * mIconWidth, pTop + mRowHeight] on this canvas
404+ if mArrayStyle then
405+ put "[" & tKeyDisplay & "]" into tKeyDisplay
406+ end if
407+
408+ fill text tKeyDisplay at left of rectangle [tLeft, pTop, mViewWidth - 3 * mMargin - 2 * mIconWidth, pTop + mRowHeight] on this canvas
382409
383410 variable tTextBounds as Rectangle
384- measure "[" & tKeyDisplay & "]" on this canvas
411+ measure tKeyDisplay on this canvas
385412 put the result into tTextBounds
386413 put tTextBounds into pDataItem["keyRect"]
387414
@@ -1317,6 +1344,14 @@ private handler setReadOnly(in pReadOnly as Boolean)
13171344 end if
13181345end handler
13191346
1347+ private handler setArrayStyle(in pArrayStyle as Boolean)
1348+ if pArrayStyle is not mArrayStyle then
1349+ put pArrayStyle into mArrayStyle
1350+ put true into mRecalculate
1351+ redraw all
1352+ end if
1353+ end handler
1354+
13201355--------------------------------------------------------------------------------
13211356--
13221357-- Scrollbar
0 commit comments