Page 1 of 3

A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 4:36 am
by Roberto Lopez
IMHO, the ugliest thing in HMG is the Browse control, but before blame me, please, let me say that this is not (mostly) my fault :)

I'll explain that:

Back in time to early 2002, I've researched about a Windows native control that could be a good host for a Browse, so, I've decided that such control should be ListView.

Very soon realized that filling it with the 'additem' method (calling as many times as rows in the table) could work for small-sized ones only, so, I've discovered the 'virtual ListView'.

The virtual ListView must not be filled in the usual way. It automatically calls an user-specified procedure (a 'callback' procedure) each time that it must draw a cell in the screen.

Such procedure receives the cell's row and column. The user must return the adequate content for that cell.

So, theoretically, you could handle billion records tables without any noticeable speed overhead.

You only should go to the required row and retrieve the data.

It worked fine for non indexed tables using dbGoto() function and was really fast.

The problem was that for making indexed tables to work in this scheme, I've needed the OrdKeyGoTo()/OrdKeyNo() functions, but by 2002 these functions were not implemented in Harbour.

Finally I've 'solved' the problem using a standard ListView containing only 'visible' records and implementing a terribly complex trickery to pretend that it was the real thing.

I've never abandoned my original idea and attempted again many years later, when the OrdKeyGoTo() and OrdKeyNo() were finally implemented, but they were very very slow,
making again impossible to use (I've attempted complex cache schemes to speed up the process with no results).

Now, I've decided to try again and guess what...?

It works smoothly and quickly now!!!

My original idea was that we should have only one table style control to handle arrays, dbf files and random data. That control should be the Grid, so I've done :)

The code attached to this message should be considered as 'pre-alpha'.

This means that it could be unstable, unreliable and (more important) that the sources are really ugly and dirty :)

So, this is not 'Test XIV' yet, this is only some thoughts in the form of code.

The final idea (if this finally works and get all browse powers) is to fully replace browse.

Is all this thing redundant, considering that Browse already is there?

The current Browse should be kept for backwards compatibility only, in the form of a wrapper for a data grid, and completely eliminated from documentation, so, at the end, will not be redundancy.
- HMG 3.0.0 (Forum Test ???) Changelog:

English:
--------

- New: Virtual Grid supports allowedit, ColumnWhen, ColumnValid
DynamicBackColor, DynamicForeColor and ColumnControls properties now.
Sample: GRID_24.

- New: Grid supports the following new things:

- 'RecordSource' Property.
- 'ColumnFields' Property.
- 'AllowAppend' Property.
- 'Buffered' Property.
- 'RecNo' Property.
- 'Append' Method.
- 'Save' Method.
- 'Refresh' Method.

These new elements are meant to give to grid, support for dbf
tables handling.

In 'Buffered' mode, adding a record, store it in a temporary
(1 record buffer). This buffer is flushed when you add another
record, with the 'Save' method or when the grid control is
released. The main advabtage of this way is that the new record
goes to the end of the grid, not being affected by current
index order (it will be ordered when saved).

'Append' has the Alt+A shortcut.
'Save' has the Alt+S shotcut.

You can set currently selected item with the 'Value'
property, as in a standard 'CellNavigation' style grid.
Alternatively you can use 'RecNo' property to set selected
item with physical record number.

'Refresh' method is meant to update changes made outside from
grid.

Is this redundant, duplicating Browse functionality?: No!

Please, read the 'Something funny happened in the way to
the browse' article in HMG Forum (http://www.hmgforum.com) for a
detailed explanation.

Sample: GRID_25.
Enjoy!

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 7:06 am
by Rathinagiri
Amazing Roberto. Do you still have only 24 hours a day? I doubt.

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 10:20 am
by esgici
Wonderful :shock: :P

Thanks a lot maestro :D

Best Regards

--

Esgici

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 12:33 pm
by Roberto Lopez
rathinagiri wrote:Amazing Roberto. Do you still have only 24 hours a day? I doubt.
I always find spare time to do funny things :)

And an important thing for people (like you and me) working with remote data is the 'grid.24' sample.

You have now full control over virtual Grid, so you can edit and add when/valid procedures, so to deal with remote data, you only need to give to virtual grid the needed info in the 'OnQueryData' procedure.

Please, give it a try...

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 12:36 pm
by Roberto Lopez
esgici wrote:Wonderful :shock: :P

Thanks a lot maestro :D

Best Regards

--

Esgici
Thanks!

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 12:48 pm
by Roberto Lopez
And...

Please test and report any problem you found!

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 12:50 pm
by Roberto Lopez
Roberto Lopez wrote: And an important thing for people (like you and me) working with remote data is the 'grid.24' sample.
Or local data coming from (ie) SqLite.

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 7:18 pm
by Rathinagiri
Unfortunately I can't compile the samples. :(

This is the error log.

Code: Select all

hbmk2: Processing configuration: C:\hmg\harbour\bin\hbmk.cfg
hbmk2: Processing: demo.hbc
hbmk2: Linking... demo.exe
C:/hmg//lib/libminigui.a(h_menu.o):h_menu.c:(.text+0x2f): undefined reference to `hb_vmProcessSymbolsEx'
C:/hmg//lib/libminigui.a(h_msgbox.o):h_msgbox.c:(.text+0x2f): undefined reference to `hb_vmProcessSymbolsEx'
C:/hmg//lib/libminigui.a(h_button.o):h_button.c:(.text+0x2f): undefined reference to `hb_vmProcessSymbolsEx'
C:/hmg//lib/libminigui.a(h_winapimisc.o):h_winapimisc.c:(.text+0x2f): undefined reference to `hb_vmProcessSymbolsEx'
C:/hmg//lib/libminigui.a(h_hotkey.o):h_hotkey.c:(.text+0x2f): undefined reference to `hb_vmProcessSymbolsEx'
C:/hmg//lib/libminigui.a(h_label.o):h_label.c:(.text+0x2f): more undefined references to `hb_vmProcessSymbolsEx' follow
collect2: ld returned 1 exit status
hbmk2: Error: Running linker. 1
gcc.exe .hbmk\win\mingw\demo.o .hbmk\win\mingw\_hbmkaut.o _temp.o    -mwindows -Wl,--start-group -lminigui -lhbmysql -lmysql -lcrypt -ledit -leditex -lgraph -lini -lreport -lhbwin -lhbziparc -lhbmzip -lmsvfw32 -lvfw32 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbvpdf -lhbmemio -lhbsqlit3 -lsqlite3 -lhbfimage -lhbpgsql -lpq -lhbtip -lhbct -lhbmisc -lhbnetio -lxhb -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib  -Wl,--end-group -odemo.exe -LC:/hmg/harbour/lib -LC:/hmg//lib -LC:/hmg/SAMPLES/GRID.24/

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 8:49 pm
by Ricci
Roberto Lopez wrote:And...

Please test and report any problem you found!
Windows XP SP3 :arrow: HMG Test XIII :arrow: Grid25 :arrow: no problems :!:

Re: A Funny Thing Happened In The Way To The Browse :)

Posted: Sun Jan 03, 2010 9:42 pm
by Vanguarda
Very very AMAZING master.

Thanks a lot.

My best regards,