Page 2 of 2

Posted: Sat Nov 12, 2005 4:31 am
by Straker
Hi Xombie! :D

I'll check it out soon. Finishing a big project this weekend....

Posted: Sat Nov 12, 2005 11:37 am
by Xombie
@Straker - Nify. Let me know what you think when you grab a look.

I just uploaded another big-ish update. Not big on updates but some internal stuff really needed fixing. The functions were totally screwed up in the expression/formula thing.

What *is* new? Well, I'm now using jack's (and everyone else involved in that project) F64 library. This is until the holy grail that is PB4 is released :) I wanted some precision so I added in his doubles code. This also adds more functions like GCD, LCM and others. However, it also introduces decimal places. Yes, even "=2+2" will result in something like "4.00000" Until I get in the numeric formatting stuff you'll have to live with it. Sorry ^_^

Also, switching between cells *should* show the proper last selected in the formula editor string.

Lastly, as an added bonus to a short term release, I've added in cell locking and formula hiding. These are in the basic form. Right now if you right-click to bring up the various menus you can select the lock/unlock or hide/unhide cells menu. Yes, I know they shouldn't be set like that. It's because it was 1am and I was already tired but wanted to update some things. Hell, I probably broke 30 other things doing this. Locking a cell should prevent the user from being able to make change to the cell. I don't have Excel installed at the moment so I don't know if it's giving any visual clues that a cell is locked so mine isn't right now. The only time you'll know a cell is locked is if you try to edit it. Hiding formulas does just what it says. If you select the cell, no formula will show up in the formula editor box. Also, double-clicking on the cell will bring up an empty edit box. It'd be super easy to pass single sheet:column:row refereces to lock single cells but it's 2:34am and I'm finally out of energy.

Fairly large warning with the locking/hiding - I have not set up sheet deletion to remove the locked/hidden cells so you'll have a leakage there until I get that updated. Sorry but I was more interested in getting this set up so users could see how it acts.

I think that's it? Super tired so I won't be surprised if I made many other bugs. I apologize ahead of time if I did.

Download here: http://www.seijin.net/Storage/xGrid-Code.rar

Let me know what you think and what you're using it for if you feel like it =_= Sleeeeeeeeeeeep

Posted: Tue Nov 15, 2005 8:36 am
by gnozal
It works fine on NT based systems, but I got a crash on Win98SE immediately after application start : pagefault in xgrid.exe at 0187:004135db

With debugger, the crash is located here :

Code: Select all

Procedure xGrid_Resize(GadgetNumber.l, x.l, y.l, Width.l, Height.l) ; Pass -1 to leave values unchanged.
   ;
   HoldWidth.l
   ;
   Protected *xGrid.s_xGrid
   ;
   *xGrid = xg_PointerFromNumber(GadgetNumber) ; <===== *xGrid = 0
   ; Fill our xGrid structure.
   If X = -1 : X = *xGrid\X : EndIf
   If Y = -1 : Y = *xGrid\Y : EndIf
   If Width = -1 : Width = *xGrid\Width : EndIf
   If Height = -1 : Height = *xGrid\Height : EndIf
   ;
   *xGrid\Width = Width - 21 : *xGrid\Height = Height - 21 ; <==== Pointer is null
   ;  ........
EndProcedure

Posted: Tue Nov 15, 2005 8:49 am
by Xombie
gnozal - I don't have anything but Windows XP. Can you try this procedure?

Code: Select all

Procedure xGrid_Resize(GadgetNumber.l, X.l, Y.l, Width.l, Height.l) ; Pass -1 to leave values unchanged.
   ;
   HoldWidth.l
   ;
   Protected *xGrid.s_xGrid
   ;
   *xGrid = xg_PointerFromNumber(GadgetNumber)
   ; Fill our xGrid structure.
   If *xGrid
      ;
      If X = -1 : X = *xGrid\X : EndIf
      If Y = -1 : Y = *xGrid\Y : EndIf
      If Width = -1 : Width = *xGrid\Width : EndIf
      If Height = -1 : Height = *xGrid\Height : EndIf
      ;
      *xGrid\Width = Width - 21 : *xGrid\Height = Height - 21
      ; Make allowances for the size of the scrollbars.
      *xGrid\TotalWidth = Width : *xGrid\TotalHeight = Height
      ; Store the size of the grid control, including the scrollbars.
      SetGadgetState(*xGrid\GadgetNumber, 0)
      ;
      FreeImage(*xGrid\Handles\Image)
      ;
      *xGrid\Handles\Image = CreateImage(#PB_Any, *xGrid\Width, *xGrid\Height)
      ;
      ResizeGadget(*xGrid\GadgetNumber, X, Y, *xGrid\Width, *xGrid\Height)
      ;
      SetGadgetState(*xGrid\GadgetNumber, UseImage(*xGrid\Handles\Image))
      ;
      HoldWidth = Int(*xGrid\TotalWidth * 0.5)
      ;
      MoveWindow_(*xGrid\Handles\ScrollHorizontal, HoldWidth + 5, Y + *xGrid\Height + 4, *xGrid\Width - HoldWidth, 16, #True)
      MoveWindow_(*xGrid\Handles\ScrollVertical, X + *xGrid\Width + 4, Y, 16, *xGrid\Height + 4, #True)
      MoveWindow_(*xGrid\Handles\Tabs, X, Y + *xGrid\Height + 6, HoldWidth - 5, 16, #True)
      ;
      SetRect_(@*xGrid\CellDimensions, -1, -1, -1, -1)
      ; Invalidate our cell dimensions.
      xg_UpdateMaxDimensions(*xGrid, #True, #True)
      ; Update with our new maximum width and height.
      xg_DrawGrid(*xGrid)
      ;
   EndIf
   ;
EndProcedure
Only added a quick *xGrid value check.

Posted: Wed Nov 16, 2005 8:43 am
by gnozal
I tried the fix ; it only moved the problem.

With the modified code, the null pointer error is here :

Code: Select all

   ElseIf Message = #WM_LBUTTONDBLCLK Or Message = #WM_RBUTTONUP
      ; User pressed the right mouse button or double-clicked a tab.  Popup custom box to modify tabs.
      If (Message = #WM_RBUTTONUP And *xGrid\Events\PopTab) Or (Message = #WM_LBUTTONDBLCLK And *xGrid\Events\TabDClick)
         ; Make sure we have an event defined for the right-click/double-click action.
         HoldIndex = SendMessage_(HandleWindow, #TCM_GETCURSEL, 0, 0)
         ;
         HoldString = Space(255)
         ;
         HoldItem\Mask = #TCIF_TEXT
         HoldItem\pszText = @HoldString
         HoldItem\cchTextMax = 255
         SendMessage_(HandleWindow, #TCM_GETITEM, HoldIndex, @HoldItem)
         ;
         If Message = #WM_LBUTTONDBLCLK
            CallFunctionFast(*xGrid\Events\TabDClick, HoldIndex, HoldString)
         Else
            CallFunctionFast(*xGrid\Events\PopTab, HoldIndex, HoldString)
         EndIf
         ;
      EndIf
      ;
   EndIf
   ;
   *xGrid\Keys\EndDown = #False ; <=========== Pointer is null
   ;
   lResult = CallWindowProc_(*xGrid\Controls\TabCallback, HandleWindow, Message, wParam, lParam)
   ;
or (sometimes) here :

Code: Select all

      ElseIf MouseLocation = #xGrid_MouseInCells
         ; We're in a grid cell.
         SetCursor_(xg_HandleSelectCell) : ReturnTrue = #True
         ;
         If xg_IsCellSelected(*xGrid, *xGrid\CellLocation\X, *xGrid\CellLocation\Y) = #False
            ; Check if the cell is already selected.
            xg_ForceSelect(*xGrid, *xGrid\CellLocation\X, *xGrid\CellLocation\Y, #False)
            ; Select the cell.
         EndIf
         ;
         If *xGrid\Events\PopCells : CallFunctionFast(*xGrid\Events\PopCells) : EndIf
         ;
      EndIf
      ;}
      ;
   EndIf
   ;
   If ReturnTrue : ProcedureReturn ReturnTrue : EndIf
   ; If we're handling the event, we'll need to let the procedure know not to continue.
   lResult = CallWindowProc_(*xGrid\OldCallback, HandleWindow, Message, wParam, lParam)  ; <=========== Pointer is null
      ;
   ProcedureReturn lResult
   ;
EndProcedure
It seems that *xGrid is not correctly initialized ?

Posted: Wed Nov 16, 2005 8:53 am
by Xombie
Hummm... is it possible that events are being fired before the grid 'control' is created and initialized? Does Windows 98 do something different than the NT OSes? I will look at adding it more catches for the *xGrid pointer return functions tomorrow in case that's the...errrr... case :)

Thanks for the heads-up and I hope you don't mind me using you as a test subject for windows 98 compatability.

How's the code otherwise? I just noticed the other day that it slows down significantly with about 1000 cells filled in on my computer :( And mine is a decently fast computer :( So I guess later I'll have to look at reworking the drawing routines.

Posted: Wed Nov 16, 2005 10:15 am
by gnozal
Xombie wrote:Thanks for the heads-up and I hope you don't mind me using you as a test subject for windows 98 compatability.
I don't mind :D

Error

Posted: Tue Dec 13, 2005 4:47 am
by phillip
hi

I tried your example and I got a error on this line
RecalculateCellReference.b
; True if the cell referenced needs to be solved. False if it's already solved or not a formula.
====> dLeft.double : dRight.double : dResult.double

Structor not found double

Posted: Tue Dec 13, 2005 5:27 am
by Xombie
Howdy, phillip.

You need the F64 library for the latest release. You should be able to grab that from this topic

viewtopic.php?t=11896

I didn't know if people were still messing around with xGrid :)

Posted: Wed Mar 29, 2006 11:27 am
by dell_jockey
Hi Xombie,

are you going to revisit your control for PB4?

Posted: Wed Mar 29, 2006 11:54 am
by Hydrate
Im using PB3.94 (and dont want to change), and it does not work(compilation error), is this for PB beta 4??

Posted: Wed Mar 29, 2006 2:39 pm
by aaron
Hydrate wrote:Im using PB3.94 (and dont want to change), and it does not work(compilation error), is this for PB beta 4??
Its for 3.94 right now, as far as I know. Do you have the F64 library installed?

Posted: Thu Mar 30, 2006 8:03 pm
by Xombie
dell_jockey wrote:Hi Xombie,

are you going to revisit your control for PB4?
Sure. I'll work on getting that updated. I imagine I can even throw in some optimization tricks that I learned in the meantime.

Oh - and for the current code - it is 3.94 and requires the wonderful F64 library.