egrid 4 grid gadget - (static PB library version.)

Developed or developing a new product in PureBasic? Tell the world about it.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Great! I also suggest a gnozal-like installer for egrid. His installer (e.g. for PureCOLOR) makes it painless to put all the required files in the right place (including examples). It's great.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice idea, but it's a question of time at the moment - or the lack of it!

I'll add that to the 'to do' list. :)
I may look like a mule, but I'm not a complete ass.
User avatar
jqn
User
User
Posts: 97
Joined: Fri Oct 31, 2003 3:04 pm

Post by jqn »

Hi srod, a little suggestion:
All function names on egrid starts by "egrid_...".
It's inconsistent whith PB commands terminology, who never uses underscore, my proposal is to delete it.

Good job.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That will break quite a lot of code! I think Thorsten in particular will scream blue murder!

Although I know a search and replace will get around this.

However, ultimately egrid will be aimed at other language developers as well as PB and so I prefer to keep it the way it is - at least for now.

Thanks anyhow.
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

The unicode version looks like it works ok, at least a very simple test I did to read in & display 10 rows of Japanese text into the grid (based on demo 1 code). Good job!

When compiling as non-unicode against the unicode lib, a compile error will be observed (I guess that's kinda obvious). I wasn't sure if all the libs can co-exist in the libraries folder (I just copied the unicode one). When coming around to the doc, it's probably worth mentioning whether all or one lib can exist in the lib folder.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

No definitely not.

You could make use of PB subsystems and place the various libs in its own folder within the PB subsystem folder. From there you then need to enable the appropriate subsytem from within the PB ide depending on which version of the library you wish to use etc.

I'll add this to the help manual - as soon as I've added a help manual! :wink:
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I'm populating an egrid using the egrid_AddRow() .. egrid_SetCellText() combination. Is there any way to set the cell text colour and/or background colour while I'm populating the grid? For example, something like:

Code: Select all

egrid_SetCellText(gadgetnum, columnindex, row, text.s, forecolour, backcolour)
Thanks.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

No, sorry.

Such formatting is the domain of CellCallback functions. I made this decision about a year ago as it saves on memory usage as the egrid library itself does not store any info on colours, fonts etc. It means that inserting rows/columns will not cause problems in that the library has to keep track of all the formatting info. Such tracking would inevitably involve API lparam values and, as already seen with PB 4, Purebasic has a habit of breaking such code! In short, it means that changes to PB will not break this lib so easily! :)

Also, it means that the egrid lib is already part of the way towards offering 'virtual grids' which I think will eventually be an important requirement for some people.

As far as I can see, the advantages of this method far outweigh the disadvantages.

Having said this of course, there's no reason why you cannot code your own procedures which 'simulate' this functionality. Shouldn't be too difficult.
I may look like a mule, but I'm not a complete ass.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

srod wrote:I'll add this to the help manual - as soon as I've added a help manual! :wink:
:D
Dare2 cut down to size
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

srod wrote:there's no reason why you cannot code your own procedures which 'simulate' this functionality. Shouldn't be too difficult.
ok I see. Well I'm gonna be lazy here, and try something - I guess you're familiar with PureCOLOR. There is a function there called PureCOLOR_SetCellColor, as per:

Code: Select all

PureCOLOR_SetCellColor(ListIconNumber.l, Row.l, Column.l, TextColor.l, BackColor.l)
Since it uses the listiconnumber as a parameter, I was wondering if I could use it with egrid. I recall you were saying your egrid is basically a redressed listicon gadget. If my simplistic view is right, is there a way to get the listiconnumber of your gadget and pass it as a parameter to this PureCOLOR function to set the colour easily? I guess this is a relatively unimportant issue compared to other things you're doing, so I wont bug you anymore with these cosmetic issues. :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I am 99% sure that this will not work!

Nothing but respect for the PureCOLOR lib, but I really cannot see that it will be compatible with the egrid lib.

The text and background are all painted at the same time (obviously! :) ) even when no CellCallback is utilised. At no point do I allow Windows to paint any part of the cell or the text etc. The egrid lib also performs other 'tasks' at this time. There is no way of disabling the egrid 'paint process' and allowing another lib to take over.

You'd have to set this up so that egrid PureCOLOR painted cells after egrid and the result, at best, would be horrendous flicker. At worst this will simply crash your program. There's also the problem of text alignment.

In order to facilitate centered and right justified text in individual cells and allowing the editing of such text without alignment problems, I do not stick to the default 'cell margins' and this could result in the PureCOLOR lib (or Windows) superimposing a second copy of the cell text upon the first.

Allowing an app to disable the painting of cells by the egrid lib will be inviting all kinds of alignment issues (particularly with the different text justifications) etc.

Let me know what happens, but I'm not very optimistic on the chances of success! 8)


**EDIT: as for getting the listicon gadget#, it's part of the egrid_CreateGrid() command. It is also returned by the egrid_CreateGrid() command (in case you use #Pb_Any etc.)
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

srod wrote:Let me know what happens, but I'm not very optimistic on the chances of success!
Yeah I just tried the PureCOLOR function by simply using the gadget num as per the egrid number, and no colour change was seen. I didn't really expect it to work, but sometimes you never know ;-)

(edit: it just occurred to me that maybe PureCOLOR is not unicode-compatible, so that might be a reason why it didn't work).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

There's also the selection border. This is painted only when the cell is refreshed and is actually positioned 'inside' the cell as opposed to around the outside. Consequently, PureCOLOR would need to draw this as well!

Nice try however.

I guess the only way would be to subclass the egrid, disable #wm_paint, then initialise PureCOLOR etc.

You'd then need to take over the painting of the entire egrid however! Believe me, getting this even half decent has taken hours and hours and hours and hours and ...... staring at individual pixels wishing I could make them disappear!

I might add 'custom cells' in which the developer could paint the contents of the cell directly etc. But in terms of normal text cells, you could easily screw the alignment up etc.

:)
I may look like a mule, but I'm not a complete ass.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

If you're looking to make the package available for use with other languages, then customisation of look/style is likely to become a big thing (either as a selling point or as a niggle point, depending on whether it is possible or not).

Anyhow, that is just a passing thought. (or was it passing wind? :))
Dare2 cut down to size
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Dare wrote:If you're looking to make the package available for use with other languages, then customisation of look/style is likely to become a big thing (either as a selling point or as a niggle point, depending on whether it is possible or not).

Anyhow, that is just a passing thought. (or was it passing wind? :))
I'm not sure what you mean there Dare? There's already a lot of customisation possible.

Do you mean 'custom cells' as mentioned above?
I may look like a mule, but I'm not a complete ass.
Post Reply