Page 1 of 5

CS-Grid-Gadget: New Release V 2.3 / PB4

Posted: Sun Nov 06, 2005 10:29 am
by CSAUER
I would like to announce the first release of my Grid library.
Why you should use this? - Here are my arguments:
- It supports instant cell input, cell locking (no input/no access), multi-selection, column/row headers, instant resizing (columns and rows), column width resizing via mouse
- Very easy to implement, take a look. You can use at most default commands
- Flexible to config. You can read-out and change nearly every parameter, like colors and style flags
- You can use multiple grids in one application
- Have direct access to redraws
- Formated cell output
- columns can have a total/summary (on a column footer)
- table can be sorted (via double-click on column header) ascending as well as descending
- table can be automatically resorted after input in sorting column/adding new row
- table can be locked completely (no access or no input)
- library returns events after entering cell, starting input, finishing input, aborting input, etc.
- Copy/Paste with clipboard
- All user-customizing can be locked
- It should be compatible to MacOSX and Linux as well, because it does not use any WinAPI command (I had no chance to test it)

UPDATED - V 2.2
Here is the link as User-Lib, incl. example:
http://www.xideas.de/purebasic/csgridgadget.zip

Here is the link for to the sources, incl. example:
http://www.xideas.de/purebasic/CS-Grid2-1-SOURCE.zip

Here is the link for to the new PB4 compatible sources, incl. example:
http://www.xideas.de/purebasic/CS-Grid2 ... SOURCE.zip
END UPDATED

UPDATED - V 2.3
Major new features and changes:
- completely compatible with version 2.2
- constant value on declaration now possible (as alternative of #PB_Any)
- cutting text on small width (orientation dependent)
- variable height of rows
- manual orientation of column headers
- manual width of row header
- manual background color for rows and/or columns
- new format: date (allows automatic date formatting)
- new format: pic (allows implementation of pictures as a value of cells - windows only)
- new inputs: combo, trackbar, combo, IP
- now released: details / sub objects
each row can have its own details screen, which can be just a gadget, a container or a sub classed CS-Grid (!)
- optimized: Column size adjustment, display sums, grid rendering, formatting, rounding, scrolling, keyboard entry

Here is the link for to the new PB4 compatible sources, incl. example:
http://www.xideas.de/PureBasic/CS-Grid2 ... ources.zip

Here is a screenshot of a working grid inside a grid:
Image
END UPDATED

Feel free to test/use this first release and post feedback to this forum.

Future plans:
- Create table according to Database String
- Save cell changes into Database, if table is linked to a database
- Changing columns via mouse drag'n'drop

Posted: Sun Nov 06, 2005 11:40 am
by Num3
Very, very nice!

I like it a lot!

Any chance to include a CSGridGadget_SetFont() command ?

Posted: Sun Nov 06, 2005 12:32 pm
by Trond
"Error: The following PureLibrary is missing: PBOSL_VB_HELPER"

Posted: Sun Nov 06, 2005 2:05 pm
by srod
Same problem as Trond is experiencing. Also, I have to switch off inline ASM to remove certain other error messages!

Posted: Sun Nov 06, 2005 7:14 pm
by CSAUER
Thanks for your quick response. I took a look into the source code, I found, that I used InStr instead of FindString in two cases. :evil: Sorry, I am an old VB guy. Now this has been changed as well as I removed all UserLibraries before I did the TailBite compilation, so that it should run well on every machine.

Additionally I added the requested 'CSGridGadget_SetFont(Gadget.l,Font.l)' command, as well as the opposite command 'CSGridGadget_GetFont(Gadget.l)'.

Please fee free to test it and give me response, if further problems appears or if you have any other wishes.

New version has been uploaded and replaced the old version.

Posted: Sun Nov 06, 2005 7:24 pm
by Trond
Very nice, but the scrollbars were kind of fat and didn't quite fit into the window. :lol:

Posted: Mon Nov 07, 2005 12:00 am
by srod
It does look good.

Having problems when using the arrow keys to select cells though (with the demo .exe). Select a few cells using a variety of cursor keys and see what happens. I get some odd behaviour with selecting/deselecting.

Regards.

Posted: Mon Nov 07, 2005 10:41 am
by Num3
Nice!

Was it programmed in PureBasic?

Posted: Mon Nov 07, 2005 4:04 pm
by CSAUER
@Num3: Yes, it uses Purebasic internal commands only - no WinAPI calls. This was a main target, to have it cross-platform. But I never had the chance to test it on other OS.

I uploaded a new version. This version supports output formatting. User fonts are drawn now. There are several pre-defined outputs as well as user-defined output. For user-defined output, you can use '#' and '0' as place-holder.
For example:
- value: 1234.212
- user-format: '##.##0,00 EUR/pc.'
- result: '1.234,21 EUR/pc.'

@srod: Regarding problem during marking with variety cursor keys, I fixed as well.

Posted: Mon Nov 07, 2005 5:35 pm
by srod
That is impressive bearing in mind there's no explicit API calls. Can I ask, are you drawing directly onto an image etc?

I say impressive, since my own effort is awash with API calls, but then I'm using a subclassed ListIcon. Have nearly finished with the various embedded gadgets allowed in each cell. But I think this work of yours has the potential to be really really flexible.

btw: still having problems with selecting via the cursor keys. Try this with the demo.exe:

select B2, key into A2, then back again. Seems as though the selection rectangle should be 'anchored' at the starting point; i.e. B2. I guess you might have designed it this way!

Posted: Mon Nov 07, 2005 5:56 pm
by CSAUER
Thanks. Yes, you are right. I am drawing direct onto an Image.
All the information are stored dynamically inside structured lists. I add all information of all grids to one list. I got one for the grid main data, for col data, for row data and cell data. The col and row data list elements are only set up, if the configuration differs from the default values. So if you change nothing in col headers, there is no waste list element.

All keyboard access is done with "AddKeyboardShortcut()", during edit, I change the shortcuts.

Regarding marking backwards. If you start B2 and you move with SHIFT and LEFT to A2, the Startpos changes from B2 to A2, so that Startpos is always <= Endpos. Does this looks like a bad behavior?

Next thing to implement should be Column ordering.
Another point is, to embedd a Container for Row details. F.ex. if you have a list of all employees, click to row head and expand employee's details. This kind of details will be in a Container and consists of standard gadgets, as well as another CSGridGadget (= sub-grid).

What do you think about this?

Posted: Thu Nov 10, 2005 4:15 pm
by CSAUER
Uploaded a new version yesterday evening.
Supports now:
- columns can have a total/summary (on a column footer)
- table can be sorted (via double-click on column header) ascending as well as descending
- table can be automatically resorted after input in sorting column/adding new row
- table can be locked completely (no access or no input)
- library returns events after entering cell, starting input, finishing input, aborting input, etc.
- All user-customizing can be locked
- Copy/Paste with clipboard
- Speed optimization
- further no API call implemented, should be transferable to all OS

Posted: Thu Nov 10, 2005 6:02 pm
by rsts
Pretty slick.

I'll have to play with it a lot more, but I sure like what I see.

Thanks for sharing.

cheers

Posted: Fri Nov 11, 2005 4:21 pm
by Num3
I would like to make a suggestion:

To create a control for entering data... Like this:

Code: Select all

+--------------+-----------------------------------------+
|  Name:       |  *** Input A ***                        |
+--------------+-----------------------------------------+
|  Address:    |   *** Input B ***                       |
+--------------+-----------------------------------------+
Well kinda of a flexgrid, but only with 2 columns (1 locked, 1 for input)
and no headers...

Posted: Fri Nov 11, 2005 4:58 pm
by CSAUER
This is pretty easy. You can do this with the existing version, just download the latest version. I added the below mentioned example as well.

Do it this way:

Code: Select all

hWnd = OpenWindow(0, 0, 0, 640, 240, #WS_OVERLAPPEDWINDOW, "Demo CS-Grid-Gadget") 
If CreateGadgetList(WindowID())
  
  test = CSGridGadget(#PB_Any,10,10,600,200,2,4)         ; Creates a CS-Grid-Gadget with 2 x 2 cells
  CSGridGadget_SetAutoRedraw(test,-1)                    ; Turns off Auto-Redraw for Grid for faster setup  
  CSGridGadget_SetColWidth(test,0,100)                   ; Defines Column-Width for Column 0
  CSGridGadget_SetColWidth(test,1,300)                   ; Defines Column-Width for Column 1
  CSGridGadget_SetCellValue(test,0,0,"Name")             ; Labels cell C:0 R:0
  CSGridGadget_SetCellValue(test,0,1,"Address")          ; Labels cell C:0 R:1
  CSGridGadget_SetCellValue(test,0,2,"ZIP")              ; Labels cell C:0 R:2
  CSGridGadget_SetCellValue(test,0,3,"City")          ; Labels cell C:0 R:3
  For y = 0 To 3
    CSGridGadget_SetCellLockStatus(test,0,y,-1)            ; Locks cells in column 0 for input (not for access)
  Next
  CSGridGadget_SetAutoRedraw(test,1)                     ; Turns on Auto-Redraw for Grid 1 after setup
  CSGridGadget_Redraw(test)                              ; Redraws the Grid
  
  ;AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_C , 1)
  ;AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_V , 2)
  
  Repeat 
      main_EventID = WaitWindowEvent()
      CSevent = CSGridGadget_EventHandling(main_EventID)                    ; Processes all Grid-Gadget events (for all CS-Grid-Gadgets)
      Select CSevent
        Case 32 ; Start input
          ;Debug "START INPUT"
        Case 33 ; End input
          ;Debug "END INPUT"
        Case 34 ; Cancel input
          ;Debug "CANCEL INPUT"
      EndSelect
      If main_EventID = #PB_Event_Menu
        Select EventMenuID()
          Case 1 ; Ctrl + C
            ;CSGridGadget_CopySelectionToClipboard(CSGridGadget_GetActualGrid())
          Case 2 ; Ctrl + V
            ;CSGridGadget_PasteClipboardToSelection(CSGridGadget_GetActualGrid())
        EndSelect
      EndIf
  Until main_EventID = #PB_Event_CloseWindow
  CSGridGadget_FreeGadget(test)                     ; Removes the Grid 1 with all sub-objects and frees memory
  End
EndIf