EsGRID grid gadget 2.1. Don't post here!

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Hi,

:o Why egrid generate massive "#egrid_UserResizeColumn" messages when I pass the mouse over the headers without attenting to resize any column?

I include comments from the egrid help file and sample code.

Thanks in advanced.

Code: Select all

;******************************************************************************************
;'egrid5' editable grid control. By Stephen Rodriguez.
;******************************************************************************************

;                                 DEMONSTRATION PROGRAM 5.


;******************************************************************************************
;This demo program sets up a simple egrid and shows how to use a CellCallback function
;to reinstate the selection box after a column resize.
;The same method can be used to reinstate the selection box after a column drag or a resize column by the user..
;******************************************************************************************


;*****************************************FONT DATA****************************************
Enumeration
  #head1
  #head2
  #main
EndEnumeration
LoadFont(#main, "Arial", 9)
;SetGadgetFont(#PB_Default,FontID(#main))
;******************************************************************************************


Procedure.l MyCellCallBack(egrid, uMsg, *cellinfo.egridCellInfo)
  Protected result
  Static oldcol, oldrow

  Select uMsg
    Case #egrid_LosingFocus
      If *cellinfo\row<>-1
        oldcol=*cellinfo\column
        oldrow=*cellinfo\row
      EndIf
      egrid_SetCellSelection(1, -1, 0,0, 0) ;Remove the selection.

    Case #egrid_UserResizeColumn
      Debug "#egrid_UserResizeColumn"
      ; *** FROM HELP FILE ***
;     #egrid_UserResizeColumn
;     Signifies that the user is attempting To resize a column in an egrid (either by clicking-And-dragging Or by double-clicking the header etc.)
;     This message is only sent If the underlying egrid has the resizecolumns creation flag set To #egrid_ResizeColumnTrue.
;     
;     Returning #True allows the column To be resized.
;     Returning #False prohibits the column from being resized      



    Case #egrid_RegainFocus
      If *cellinfo\param=#egrid_ResizeColumn Or *cellinfo\param=#egrid_DragColumn 
        egrid_SelectCell(1, oldcol, oldrow, 0)
;        egrid_SetCellSelection(1, oldcol,oldrow,1,1)
      EndIf
    Default 
      result = #True                       ;This accounts for all messages we have decided not to process.
  EndSelect
  ProcedureReturn result
EndProcedure
;******************************************************************************************


;*************************************WINDOW + GADGET LIST*********************************
If OpenWindow(0,0,0,640,300,"egrid4 demo 5.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  ;******************************************************************************************
  
  
  ;********************************************EGRID*****************************************
  ;Create an egrid with resizable columns.
  egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,28,#egrid_HeaderDragDrop|#egrid_GridLines, #egrid_ResizeColumnsTrue)

  ;******************************************************************************************
  egrid_CreateCellCallback(1, @MyCellCallBack())
  egrid_SetHeaderHeight(1, 26)
  egrid_SetOption(1, #egrid_HeaderBorderColour, #Red)
  egrid_SetOption(1, #egrid_SelectionBorderColour, #Blue)
  egrid_SetOption(1, #egrid_SelectionBorderWidth, 2)

  ;********************************************TEXT GADGET***********************************
  
  ;***************************************ADD COLUMNS AND ROWS TO EGRID**********************************
  egrid_AddColumn(1,0,"",60)
  For b=1 To 4 ;50 columns. 
    egrid_AddColumn(1,b,"Col " + Str(b-1),60)
  Next
  egrid_AddRows(1,-1, 100) ;Add 100 rows.
  For b=0 To 99            
    egrid_SetCellText(1, 0,b, "Row "+Str(b))
  Next
  
  ;*****************************************EVENT LOOP***************************************
  Repeat
    EventID = WaitWindowEvent()
    
    Select EventID
      
      Case #PB_Event_Gadget
        Select EventGadget() 
        EndSelect
    EndSelect
  Until EventID = #PB_Event_CloseWindow
  
EndIf
  
End
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

QuimV wrote:Hi,

:o Why egrid generate massive "#egrid_UserResizeColumn" messages when I pass the mouse over the headers without attenting to resize any column?
If you choose to create an egrid with the style flag #egrid_ResizeColumnsFalse then no #egrid_UserResizeColumn messages are sent at all.

On the other hand if you use the flag #egrid_ResizeColumnsTrue, then you can still prevent the columns being resized at runtime by responding to the #egrid_UserResizeColumn message. In this case, egrid needs to know if you are preventing the resize of a particular column whenever the mouse passes over the divider in order to prevent Windows from changing the cursor to the resizing one. Preventing the resize is one thing, stopping windows displaying the sizing cursor is another.

The message is required because egrid does not store any information on individual cells or columns etc. instead relying on the CellCallback function when provided.

I am toying with the idea of getting egrid to store information on cells and columns/rows etc. but this then makes setting up the initial egrid a little more cumbersome in my opinion.

I hope this answers your question. :)
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Hi,

In my opinion this message shoud be sent only when the user is attempting to resize a column. I mean that will be true when the user clicks LeftButtonDown and then LeftButtonUp (dragging or double-clicking as you show in the help file, - the trigger will be the Mouse click).

I will try to do that using the LeftButtonDown and LeftButtonUp messages and a static flag inside my callback function.

Thanks a lot for your answer, srod.
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

QuimV wrote:Hi,

In my opinion this message shoud be sent only when the user is attempting to resize a column. I mean that will be true when the user clicks LeftButtonDown and then LeftButtonUp (dragging or double-clicking as you show in the help file, - the trigger will be the Mouse click).
But, as I explained, in the case that I do not send the #egrid_UserResizeColumn message at these times, Windows will automatically display the sizing cursor even when you've denied permission for an individual column from being resized.

I don't see what the problem is in firing multiple #egrid_UserResizeColumn messages, I mean all egrid is essentially doing is passing on the Windows message WM_SETCURSOR etc. which will be sent regardless of whether egrid converts them to #egrid_UserResizeColumn or not.
I may look like a mule, but I'm not a complete ass.
michel
Enthusiast
Enthusiast
Posts: 142
Joined: Mon Feb 19, 2007 5:47 pm
Location: Luxemburg

Post by michel »

Hello Srod,

Thank you for your answer. Of course I use egrid 5. I would be pleased to get an example, you can send it to the same address as the registration code yesterday.

Other question: Is there already a possibility to reduce the height of a cell in order to get a few more rows on a window?

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

Post by srod »

Afraid that all rows have the same height in an egrid. You can change this height, but it affects all rows.
I may look like a mule, but I'm not a complete ass.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

When clicking a cell you get a message:

#egrid_LeftButtonDown

Releasing gives:

#egrid_LeftButtonUp

But if you click twice slightly faster (not a double click speed though), you get just one leftbuttondown and two leftbuttonups.

Is this correct, a bug or just my machine?

Otherwise GREAT! :D
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
ebs
Enthusiast
Enthusiast
Posts: 557
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

srod,

Most of your egrid5 example programs no longer work because they use the removed command egrid_AddRow().

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

Post by srod »

I have just checked all example programs in the install and they all use egrid_AddRows().

You must be combining the new libraries with the old examples somehow.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

DoubleDutch wrote:When clicking a cell you get a message:

#egrid_LeftButtonDown

Releasing gives:

#egrid_LeftButtonUp

But if you click twice slightly faster (not a double click speed though), you get just one leftbuttondown and two leftbuttonups.

Is this correct, a bug or just my machine?

Otherwise GREAT! :D
Yes, this could be 'normal'. The reason I didn't add a double click message is because the first click brings up the edit control (if the cell is of string type) and the second will register with the edit control. What you are seeing could be part of this same process.

I wouldn't worry too much about it. :)
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update - egrid 5 version 1.02.

Have refined the cell selection process so that the selection automatically scrolls even when the cursor is not over the egrid (the previous version was slightly flawed in this respect).

Have rewritten the code responsible for creating borders etc. This has led to a vast improvement in the selection rectangle when selecting cells (in that it is no longer disjointed!) It looks a lot better now.

(Have uploaded an updated package with the static libraries, the dll version still requires updating which I'll do tonight.)

egrid forum: http://egrid.aceboard.com/
egrid website: http://www.purecoder.net/egrid.htm
I may look like a mule, but I'm not a complete ass.
ebs
Enthusiast
Enthusiast
Posts: 557
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

You must be combining the new libraries with the old examples somehow.
srod,

You're absolutely right - sorry about the confusion.

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

Post by srod »

No worries.

:D
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Update - egrid 5 version 1.03.

Bugfix!

Have also updated the dll version to bring it in line with the static library version etc.

egrid forum: http://egrid.aceboard.com/
egrid website: http://www.purecoder.net/egrid.htm
I may look like a mule, but I'm not a complete ass.
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

srod wrote:Have replaced the command egrid_AddRow() with egrid_AddRows().
HELP! What have you done? :wink:
I've to change over 20 'egrid_SetOption()' and 'egrid_AddRows()' in my program.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Post Reply