From: Ariel S. <as...@ya...> - 2005-02-22 21:42:34
|
I've been toying with the listview wrapper idea that I brought up last week. I threw together a module to show off the basic idea, though it needs to be reworked. I wanted to make it easy to set up a listview and keep track of the items by some id. When I started writing this, I used the hashref-of-hashrefs idea like DBI returns from fetchall_hashref() because it seemed like a good way of matching name/value pairs up with their respective ids. The problem with this is that there currently isn't a good way to sort the items in the listview because of the nature of hashing. If you're interested in having a look, I have the rough module and a test script here: http://www.serbin.org/ariel/mms.zip I can easily fix this up to suit my immediate needs, but I think that it would be nice to make it more generic so that it would be helpful to others. If anyone has any opinions as to how this could be better implemented, please offer them up... -Ariel |
From: Johan L. <johanl@DarSerMan.com> - 2005-02-22 23:03:07
|
At 22:42 2005-02-22, Ariel Serbin wrote: >I started writing this, I used the hashref-of-hashrefs >idea like DBI returns from fetchall_hashref() because >it seemed like a good way of matching name/value pairs >up with their respective ids. The problem with this Good work! I wrote a few comments on the interface and stuff, but then this thought struck me: Have you considered subclassing Win32::GUI::ListView and just add the ability to specify an optional -id when adding an Item? This would have the great advantage of being backwards compatible with the ListView control, and more people could "just start using it" because they already know the interface and the only new thing would be how to manage the id. Actually, a patch to Win32::GUI::ListView could be an excellent contribution to the Win32::GUI project itself. There are far too few small, practical utility methods being submitted to the module. /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos johanl AT DarSerMan.com Latest bookmark: "TCP Connection Passing" http://tcpcp.sourceforge.net/ dmoz: /Computers/Programming/Languages/JavaScript/ 12 |
From: Ariel S. <as...@ya...> - 2005-02-23 01:14:29
|
--- Johan Lindstrom <johanl@DarSerMan.com> wrote: > Have you considered subclassing Win32::GUI::ListView > and just add the > ability to specify an optional -id when adding an > Item? This would have the As someone who has come to rely pretty heavily on Win32::GUI, I did think about subclassing/modifying the ListView object, but I have a few good reasons why I didn't go that route. First of all, I'm not much of an OO programmer. I like to encapsulate my modules as objects, but have only done the most basic of inheritance type stuff. Secondly, I don't really understand how Win32::GUI works. I've never done XS and the whole thing is a bit of a black box to me. I would love to muck about in Win32::GUI::ListView::Add() if only I could find it! Finally, as I understand it (see preceding paragraph for qualifications), Win32::GUI is basically a wrapper that calls some functions in some windows dll. I'm not sure if it's appropriate to be beefing it up with too much perl-side logic. For that reason, subclassing it seems more natural than altering the module itself... |
From: Ariel S. <as...@ya...> - 2005-02-23 21:50:33
|
I made some changes to my wrapper module that I mentioned the other day. I had considered the sorting issues that Joe mentioned and added sorting routines similar to the code that he posted. The wrapper now has a sorting scheme that defaults to a regular cmp, but lets you pass in a sub to convert the data if you want. For an example, uncomment the code in the lv_ColumnClick event handler in my new test script: http://www.serbin.org/ariel/mms.zip So far, this seems to be a pretty handy way to manage listviews for me. The think that I like about it is really easy to show the results of the query and the wrapper can return either the relevant ID or the underlying data. (see the mybutton_Click handler for an example.) In one app that I'm working on, I'd like to let the user decide which columns they would like to see in the listview. At first, I had planned to just write something to collapse unwanted columns to 0 width, but I think that using this module is much more intuitive. I also like the fact that the "rows" are not limited to what is shown in the listview. As always, thoughts are appreciated. -Ariel |