xList - Super ListIcon (Beta)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
rw
User
User
Posts: 27
Joined: Mon Sep 04, 2006 9:55 pm

Post by rw »

Hello Xombie,

really good work.

I am testing your Xlist with my MP3-Application.

I am missing some commands:

- a command to set a filter
- a command to set a cell value (I dont understand your "TestGetData-Procedure"

Greetings

rw
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Yes.. with a menu-option it would be fine too ..

I fond the problem with the download... :roll:
firefox (I am using) always downloaded the file from cache.. so cleaning up the cache solved the problem ... (I apologize for the inconvenience I made to you :oops: )
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Post by ozzie »

Thanks for removing the need for having PureDispHelper installed. A few extra facilities I would need (some of which I note are already in your list of planned enhancements):
  • Allow user to change column width, preferably by dragging a column divider in the header.
  • Ability to get the current column widths and positions, so next time the program is run it can redisplay the list in the same format
  • Ability to set a row's text color
  • An event to be raised when the user selects a row, so the program can detect which row was selected
I also found that the test program fails if you click twice on the column header of a 'double' column (eg column 3). This may be data related as the program doesn't fail if I reduce the number of rows from 10000 to 100.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

@rw - There is a command to set a filter dynamically. It will clear out any existing filters and set it as a range type: xListSetColumnFilter() I will try to put an example together for you tonight on that and how you current set a cell value. The way it works at the moment is that xList will request the values via a callback procedure and you pass it what it needs. It was made this way for database applications in general but also because of speed and the way columns are independent. I'll be adding in the ability to add rows one at a time in a future date.

@walker - I'll put something together for you and try to have it done this evening.

@ozzie - you should be able to resize columns just like a normal listicon by moving your mouse over the column dividing lines, clicking and holding down and resizing. It should change the mouse cursor when you're over the dividing lines. I will add in a get/set column width for you. That's easy. For the row text color does that affect all text within the row and set them all to the same color? I have one for the row background color but not currently text color. I'll make a selection event. Easy enough.
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Post by ozzie »

Xombie wrote:@ozzie - you should be able to resize columns just like a normal listicon by moving your mouse over the column dividing lines, clicking and holding down and resizing. It should change the mouse cursor when you're over the dividing lines.
Hmm. Must be something to do with my development PC. I tried the test program on two other PC's and they both changed the mouse cursor, but my dev pc doesn't. Ignore that one!
Xombie wrote:I will add in a get/set column width for you.
Thanks.
Xombie wrote:For the row text color does that affect all text within the row and set them all to the same color?
Yes - I want to set both the background color and text color of the whole row.

btw, is Xlist cross-platform? I'm developing under Windows at the moment but want to support MAC OS/X and Linux as well.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

I've updated the code to include some bug fixes and features.

Download...
The String column type now allows for 'Contains' and 'Begins With' filtering...

Image

There is now an event for selection and the zip file contains an example of this. The function is called whenever a row is selected and it will return a pointer to structures with values from that row. They are not direct memory pointers to the row information so you cannot change the base data using those structures.

I've added the ability to set a row background and foreground color. Use #PB_Ignore to not set one and use -1 to clear the color. Click the 'Test 2' button in the example to see how this works.

I've also added a get/set column width function. Click 'Test 1' in the example to see how this works.

I've also included an example (the 'Test 3' button) on how you can set a column filter using a procedure call.

I think that's about it for the moment. Still quite a bit to do.

xList is not currently cross platform. A thought for later versions, perhaps? At least on Linux. I don't have anything for the Mac.
rw
User
User
Posts: 27
Joined: Mon Sep 04, 2006 9:55 pm

Post by rw »

Hello,

thank you for the improvements. The SetFilter command comes in handy.

Now I need a XlistSetWidth/Height to resize the Xlist and some kind of "cursor movement".

For example: Click on a cell, color the cell, then move with the arrow keys.
For this, a command to get a cell position and to set a cell color is needed.

Wishes over wishes ... :-)

I think there is an error in the filter. It seems it does not filter a (Blank) value.

Thanks fpr your work.

rw
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Howdy,

Use the normal ResizeGadget() command to resize but use xListGetWidth() and xListGetHeight() to retrieve the width and height.

For your cursor movement - I'm afraid to say that xList is not going to go down the grid path. I plan to allow color cells individually but not to select cells by themselves and show as selected.

Perhaps what you need can be accomplished in a different way? What are you trying to do with the cursor movement / cell selection?

Lastly, can you give me more information on the filter problem? Is this when you right-click a string type column and select the blank option at the top of the menu?
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

...tried to use it to show a table content of a database... but I didn't manage to set up the rows... Is it only possible like in your example via a callback? ... much to complicated ... (imho; and i don't understand it at all...)
Could you provide a simple command like xlistSetData(#xlist, row, col, data_to set) or similar?
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Currently only possibly via callback but I will add a command to add rows of data manually - like AddGadgetItem(), right?

The thing is - especially with a database, the callback is very fast at filling in information. Much, much faster than adding line by line.

I'll give you an example of how I use it and maybe you'll see why I prefer this method (especially with databases). I use PostgreSQL for a client program at work. Most of the listicons in use are driven by queries. The old way would be for me to loop through all rows and call AddGadgetItem() with a chr(10) delimited string of the whole row. This is a pretty slow method because you're slowly increasing the size of the listicon row by row.

xListPrepareRows() works by passing the total number of rows and the procedure that fills in the data. With the total number of rows the procedure can pre-allocate the necessary amount of memory and save time / speed in that way. Next, it uses your callback to populate the rows and columns. xListPrepareRows() requests it's information by calling your procedure and passing the row and column it needs. Your procedure just fills in the information as needed.

This works well for me because I will open a connection to my database, run the query and then call the xListPrepareRows() procedure. When the procedure calls the data requester procedure, I just do a Peeks(PQGetValue(*HoldResult, Row, Column)) and get the information required.

It might look complicated but it's actually really easy - especially in database scenarios.

How about you post a code sample and I'll fix it up with how it would work in xList. That'll give you a good example to work from.
rw
User
User
Posts: 27
Joined: Mon Sep 04, 2006 9:55 pm

Post by rw »

Hi,

Resizing with ResizeGadget seems obvious :-). Thank you.

The filter problem:

When you right click a column and set a filter it filters the next entry. If you filter the last entry in the list you get a memory exception error.

My cursor movement: Do you think it is possible, that you get the cell row/col if you click at a cell (perhaps with a event). Then with the possibility to color a cell i could simulate a "cursor".

rw
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Download Update Here

I've updated the code to allow for manually adding rows. The demo shows this with the "Test 4" button. Rows are added in sort order if the list is sorted or at the end if nothing is sorted. I debated on how to handle this the best way and that's what I came up with since xList is so focused on multi-column sorting, filtering and etc... It didn't make sense to allow insertions at specific indexes. Adding rows works by creating space in the list and returning that address to the procedure. You put in the values you need and then call the xListFinishAddRow() to actually insert the row into the list.

Code: Select all

Procedure TestAddRow()
   ;
   Protected *Memory.l
   ;
   Protected HoldSize.l
   ;
   Protected *Position.l
   ;
   Protected *HoldAdd.s_xList_Add_Row
   ;
   *Memory = xListAddRow(#ListMain, @HoldSize)
   ;
   If *Memory
      ;
      *Position = *Memory
      While *Position - *Memory < HoldSize
         ;
         *HoldAdd = PeekL(*Position) 
         ;
         If *HoldAdd\ColumnID = #List_Column_3
            *HoldAdd\DoubleValue = 325252.3151
         ElseIf *HoldAdd\ColumnID = #List_Column_2
            *HoldAdd\StringValue = "Hello Purebasic!"
         ElseIf *HoldAdd\ColumnID = #List_Column_4
            *HoldAdd\BooleanValue = #True
         Else
            *HoldAdd\IsNull = #True
         EndIf
         ; 
         *Position + 4
         ;
      Wend
      ;
      xListFinishAddRow(#ListMain)
      ;
   EndIf
   ;
EndProcedure
There are also quite a few bug fixes in the code. Hopefully I didn't add any new ones with this ^_^;

One other thing. I forgot to change a part in the demo code. Switch the current structure to this...

Code: Select all

CompilerIf Defined(s_xList_Hold_ColumnRow, #PB_Structure) = #False
   Structure s_xList_Hold_ColumnRow
      ;
      ID.l
      ;
      Format.l
      ;
      RowType.l
      ;
      StructureUnion
         LongValue.l
         DoubleValue.d
         StringValue.s
         BooleanValue.b
      EndStructureUnion
      ;
      PointerRow.l
      PointerColumn.l
      ;
   EndStructure
CompilerEndIf
This adds PointerRow and PointerColumn which will return the address for those structures. This allows you to modify the actually contents of a row using the xListGetRowValues() procedure. I call it like...

Code: Select all

*Address = xListGetRowValues(#ListInventoryHistory, Row, @Size)
Where Row is the row number you're interested in. Size is filled with the size of the returned memory. You can then enumerate through the row values like...

Code: Select all

Protected *HoldTemporary.s_xList_Hold_ColumnRow
Protected *HoldRow.s_xList_Rows
*Position = *Address
While *Position - *Address < Size
   *HoldTemporary = PeekL(*Position)
   If *HoldTemporary\ID = #List_Column_1
      *HoldRow = *HoldTemporary\PointerRow
      *HoldRow\LongValue = 2385562
   EndIf
   *Position + 4
Wend
You'd just need to call xListRefresh() if you make changes.

Sorry for the delay on the updates. I have a huge project due at work that eats all of my time.
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Post by Tomi »

Hello
Please update down link, it is broken now :cry:
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Tomi,

I just checked and it's working: http://www.seijin.net/xList/xList.zip

Please let me know if you still have problems with it.
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Post by Tomi »

very well, it is donload now.
I interest to test it :)
Thanksful Mr.Xombie
Post Reply