here is the result of my recent working on the ListView class to bring some missing features.
Some time ago I’ve added support for Icons/Images in the ListView items but it was a raw implementation without configuration possibilities so I added some tags definible at creation time that allow to configure this feature at a deeper level. Here are the supported tags:
By default the icon size is equal to the row height (EntryHeight tag), using this argument you can adjust the icon/image size to suit your needs.
By default the icons is placed at x = 0, to the extreme left. Using this tag you can adjust the horizontal position.
Defaults to False. If you set this tag to True the icon/image is used as the ListView’s row background.
Defaults to False. With the default setting the icon/image will be resized (keeping the aspect ratio) so that it is entirely visible, but if the image size does not match with the aspected size you can have borders (transparent). Setting this tag to True the icon will be maximized so that you will not have borders but the image could be not entirely visible.
Defaults to 0. It represent the space in pixels between the icon and the text.
Defaults to False. With the default setting, items with no icon/image will be rendered starting from the left so you can have not not prefectly aligned items. If you set this tag to True all items will be aligned.
Working with ListViews I’ve also faced new problem.
Suppose you want to make a ListView with two columns, one with file names and one with file sizes: if you are goin’ to specify the file sizes in bytes it’s all fine.
But what happen if you try to pass the file sizes in (let’s say) kilobytes and adding the suffix ‘Kb’?
Well, if you convert by hand your values and you create the ListView you will see that when you click on the column header the sorting will mess up all your entries because they will be sorted as strings and, for example, in string sorting ’15Kb’ comes before ‘3Kb’. So how can we solve this thing?
I’ve implemented a new tag called ColumnHandlers, a table where you can specify your custom functions to convert values on the fly when the ListView is rendered. This implementation will easily solve our problem infact if we specify our values in bytes and we provide this converting function…
Function(value) Return((value/1024) .. "Kb") EndFunction
…everytime the values in the specified columns are rendered the values are converted using the given functions, in our example the values are converted in kilobytes and the “Kb” string is added to the result.
Now when you click in the header button the sorting produce the expected result.
This implementation will also provide nice side effects, for example it’s easy to force a column to be rendered in uppercase characters using this method or in bold style or anything you like without influencing the original data and the sorting processes.[wp_ad_camp_2]
I’ve also added these utility functions:
Returns True if a gadget with the given name exists, otherwise returns False.
Returns True if the given status is valid or not, this function is used internally during the gadget creation process.
I’ve also fixed these bugs:
- Fixed a bug in the AltCode argument in window’s hotkeys detection
- An exception was raised when trying to hide a window if there was only one window defined.
And that’s all for today![wp_ad_camp_2]