Work in progress - xGrid

Developed or developing a new product in PureBasic? Tell the world about it.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Work in progress - xGrid

Post 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! ^_^
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

It looks nice.
Remember scroll wheel support.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

very good Xombie :)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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!
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Post by sec »

Very nice! Keep good job!
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Very interesting.
Last edited by rsts on Fri Sep 16, 2005 10:14 pm, edited 1 time in total.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Nice.
When hovering the columns headers, the cursor sometimes disapear.
Win2000 SP4
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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.
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post 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)?
~I see one problem with your reasoning: the fact is thats not a chicken~
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post 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.
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post 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!
~I see one problem with your reasoning: the fact is thats not a chicken~
Post Reply