Page 1 of 3

Work in progress - xGrid

Posted: Fri Sep 16, 2005 9:25 am
by Xombie
This is a very very very early version of something I am working on. As such, it's not a code release but an exe to try out. It's all PB commands and WinAPI.

Basically, I'm trying to create a spreadsheet ala Microsoft Excel. I'm starting from the ground up building a custom 'control'. This is all hand drawn. There is no "real" limit to the number of columns and rows but for the purpose of this demo, I've limited it. The limit is not hard coded so it can be removed very easily.

The only things you can do currently in the demo is resize columns or rows, select columns or rows (even ranges) and scroll.

The base code is in place to allow multiple 'sheets' per control. Also, since I'm hand-drawing everything, it will be no problems at all to have all kinds of nice formatting per cell. Colors, alignment, etc... Multiple types will work per cell - strings or numbers (probably add in jack's nice double library for better math stuffs), etc... Sorting or whatever can be added nicely.

The nice thing about the way I have it set up is that it's all virtual. That's why it can display a theoretically unlimited amounts of rows and columns. They don't actually exist. The only time they exist is if you make a change to them. For example, I don't store the widths of the columns unless you change them. And then I store the width only for the columns that are changed. Fairly lightweight.

I'll work with it until I finish the current part and add in the cell manipulation and then I will post the code. Not sure if I will continue working on it after that. I guess it depends on if there's interest in it.

Without further ado, here is the program. It's an exe compressed by rar so just unrar it. No code is publicly available yet.

http://www.seijin.net/Storage/xGrid.rar

Let me know how it looks. No need to give me bug reports as I'm very aware of what current problems are ^_^ I'm just curious as to what y'all think of it so far. If it looks promising or not. I should have cell text editing by Monday (it's late Thursday night now).

EDIT: Fixed broken link. Sorry! ^_^

Posted: Fri Sep 16, 2005 9:47 am
by thefool
It looks nice.
Remember scroll wheel support.

Posted: Fri Sep 16, 2005 10:24 am
by Xombie
Thought it might be fun to try it so I added a simple mouse wheel scrolling thingie real quick. Cheers :D

Download at the same spot.

Posted: Fri Sep 16, 2005 11:53 am
by jack
very good Xombie :)

Posted: Fri Sep 16, 2005 12:10 pm
by thefool
Xombie wrote:Thought it might be fun to try it so I added a simple mouse wheel scrolling thingie real quick. Cheers :D

Download at the same spot.
works!
btw, middle-mouse-button-click would be nice too. so you get the vertical scrolling too!

Posted: Fri Sep 16, 2005 12:14 pm
by sec
Very nice! Keep good job!

Posted: Fri Sep 16, 2005 5:23 pm
by rsts
Very interesting.

Posted: Fri Sep 16, 2005 9:09 pm
by Blade
Nice.
When hovering the columns headers, the cursor sometimes disapear.
Win2000 SP4

Posted: Sat Sep 17, 2005 2:55 am
by Xombie
Thanks for the kind words.

@thefool - should be easy enough to do. I did a little test to see if it was possible without a huge amount of work and it looks promising ^_^

@Blade - I will watch out for that. You mean you just leave the mouse on top of the column headers and, without moving the mouse at all, the cursor will sometimes vanish?

UPDATE: I made some code updates.
  • 1. Multiple row, column and cell selections should work by holding down the control key.
    2. Cell selection should be working now. The column and row headers will 'light up' based on what cell is selected.
    3. New cursor when mouse is over a cell.
    4. When making a single cell selection or a contiguous cell range selection, a border will be drawn around the cell or range. A little rectangle will be drawn in the lower-right corner for possible future usage.
    5. Various bug fixes and internal enhancements.
It may seem like only a couple changes but they were difficult to do >_> Tricky working with selections in code like this. It took some interesting code to make the multiple rows/columns/cells selection work. Even more tough to figure out how not to overwrite previous selections when doing a new range selection with the control key down <_<

Also, if you ever say to yourself, "Hey, this looks kinda like Excel..." well, yeah, I'm basing the look and some of the functionality on Excel.

Download at the same place ^_^

UPDATE 2: Made it so that a single cell selection will not have a blue-ish 'fill' and will instead only have the black border. And updated it to 'light up' the column and row header for the cell. As always, download at the same place.

Posted: Sat Sep 17, 2005 8:49 am
by thefool
Major bugs in the new version!

The cursor is NOT visible at all.
When a cell is selected, the black rectangle is ok, however there is a small
rectangle too to the bottom right side, wich stays there when i scroll!
so it keeps being on the screen.

Posted: Sat Sep 17, 2005 10:59 am
by Xombie
Ohhhhhhhhhhhhhhhhhh.

No wonder Blade was having problems. I feel stupid. Fixed the vanishing cursor and the floating rectangle.

The vanishing cursor is because I don't know how to include the cursors in the exe and then load them from within the exe. I thought I could do a IncludeBinary but I don't know how to read that back. LoadCursor_() does not seem to work if I tell it to use ?Label. Any ideas? In the meantime, I'm including the custom cursors with the *.rar file.

No wonder, Blade :)

Download at the same place.

Posted: Sat Sep 17, 2005 11:34 am
by srod
Nice work there.

A slight bug though. Widen a column, then widen a row and if I then click in the cell lying in both the resized column and the resized row, the incorrect cell gets selected.

Impressive work nevertheless.

Posted: Sat Sep 17, 2005 11:46 am
by Killswitch
Very impressive indeed! I've always wondered if anybody would be able to recreate Offive with PB and it looks like this is a great first step. I wonder, do you think it will be possible to make a Word control (you know, the blank page that you write on)?

Posted: Sat Sep 17, 2005 4:31 pm
by Xombie
srod wrote:Nice work there.

A slight bug though. Widen a column, then widen a row and if I then click in the cell lying in both the resized column and the resized row, the incorrect cell gets selected.

Impressive work nevertheless.
I forgot to reset 1 single variable :oops: Glad it was something easy, though :D Now that the selection code is more or less fixed, I can concentrate on working more with text and formatting.

Until I get home, please download from the Pure Basic myftp server.

File:1->xGrid.rar
Image

@Killswitch - I'm planning on making a simple spreadsheet but I don't think I personally will be doing any other 'office' products. Should be easy-ish to do some Word type program with the scintilla stuff right? Hell, maybe we could each pick a product and do a PureOffice :) Small, single executables. If I actually do make a full spreadsheet I can't see it going beyond a single 100-150k exe file. That'd be attractive to some people to have a simple spreadsheet program that small, right?

Update: Yet another update to fix a problem when making multiple cell selections. Still download from myftp.org link in this post.

Posted: Sat Sep 17, 2005 11:31 pm
by Killswitch
D'ya know that's exactly what I was thinking! I'm not sure if scintilla would work (is it soley tied to edior gadets, or the 'scintilla' gadget?) - I was thinking more of something from scratch like this :D .

PureOffice would deffinatly be cool though!