Page 23 of 25
Posted: Fri Jan 19, 2007 9:52 pm
by srod
ts-soft wrote:sorry, new problem
If UserResizeColumn, egrid looses the selection
Thomas
This is by design, mainly because of difficulties with win 98.
See demo program 5 for an example of how to easily reinstate the selection box after a column resize.

Posted: Fri Jan 19, 2007 10:00 pm
by ts-soft
srod wrote:See demo program 5 for an example of how to easily reinstate the selection box after a column resize.

thx, this works okay

Posted: Tue Feb 13, 2007 9:17 pm
by zikitrake
Hi, in the EGRID DEMO3, how can I maintaining the selection with the GRID in readonly mode?
Code: Select all
;******************************************************************************************
;'egrid4' editable grid control. By Stephen Rodriguez.
;******************************************************************************************
; DEMONSTRATION PROGRAM 3.
;******************************************************************************************
;This demo program sets up a simple egrid with some button type cells.
;It also shows how to dynamically colour cells as the user moves the selection around.
;******************************************************************************************
;XIncludeFile "egrid4.pb"
DisableExplicit
;*****************************************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
Select uMsg
Case #egrid_SelectCell
;Here we arrange for the selected row and column to be coloured blue.
;This requires a complete redraw of the egrid.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_LosingFocus
;As part of colouring the selected row and column blue, we must arrange to clear these
;colours whenever the selection box is removed.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_NotifyCellType
If *cellinfo\column=0
*cellinfo\celltype=#egrid_Button
EndIf
Case #egrid_FormatCell
If *cellinfo\row<>-1 And *cellinfo\row=egrid_SelectedRow(1); And *cellinfo\column=egrid_SelectedColumn(1)
*cellinfo\backcolour = $A5F4F9
ElseIf *cellinfo\row<>-1 And (*cellinfo\row=egrid_SelectedRow(1) Or *cellinfo\column=egrid_SelectedColumn(1))
;*cellinfo\backcolour = #Blue
;Debug Str(*cellinfo\row)+" "+Str(*cellinfo\column)
EndIf
Case #egrid_CellButtonClick
Debug "Clicked row "+Str(*cellinfo\row)
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 3.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#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,26,#egrid_GridLines, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
;******************************************************************************************
egrid_CreateCellCallback(1, @MyCellCallBack())
egrid_SetHeaderHeight(1, 26)
egrid_SetOptions(1, -1, #Black, 2, -1) ; gadgetnum, header border colour, selection border colour, selection border width, gridline colour
;********************************************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
For b=0 To 99 ; Add 10 rows.
egrid_AddRow(1,-1)
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
Thank you for this great lib!
Posted: Tue Feb 13, 2007 9:22 pm
by srod
Hi, I'm not sure what you mean by read-only mode? Do you mean that you wish to prevent the editing of cells?
Posted: Tue Feb 13, 2007 9:28 pm
by zikitrake
srod wrote:Hi, I'm not sure what you mean by read-only mode? Do you mean that you wish to prevent the editing of cells?
Yes!... sorry, my english is very(very very) bad!

Posted: Tue Feb 13, 2007 9:30 pm
by srod
The quickest way is to switch all cells to type #egrid_StaticString.
Code: Select all
;******************************************************************************************
;'egrid4' editable grid control. By Stephen Rodriguez.
;******************************************************************************************
; DEMONSTRATION PROGRAM 3.
;******************************************************************************************
;This demo program sets up a simple egrid with some button type cells.
;It also shows how to dynamically colour cells as the user moves the selection around.
;******************************************************************************************
;XIncludeFile "egrid4.pb"
DisableExplicit
;*****************************************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
Select uMsg
Case #egrid_SelectCell
;Here we arrange for the selected row and column to be coloured blue.
;This requires a complete redraw of the egrid.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_LosingFocus
;As part of colouring the selected row and column blue, we must arrange to clear these
;colours whenever the selection box is removed.
;The actual colouring has to be notified in the #egrid_FormatCell message below.
result=#True
RedrawWindow_(GadgetID(1), 0, 0, #RDW_INTERNALPAINT|#RDW_ERASE|#RDW_INVALIDATE)
Case #egrid_NotifyCellType
If *cellinfo\column=0
*cellinfo\celltype=#egrid_Button
Else
*cellinfo\celltype=#egrid_Staticstring
EndIf
Case #egrid_FormatCell
If *cellinfo\row<>-1 And *cellinfo\row=egrid_SelectedRow(1); And *cellinfo\column=egrid_SelectedColumn(1)
*cellinfo\backcolour = $A5F4F9
ElseIf *cellinfo\row<>-1 And (*cellinfo\row=egrid_SelectedRow(1) Or *cellinfo\column=egrid_SelectedColumn(1))
;*cellinfo\backcolour = #Blue
;Debug Str(*cellinfo\row)+" "+Str(*cellinfo\column)
EndIf
Case #egrid_CellButtonClick
Debug "Clicked row "+Str(*cellinfo\row)
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 3.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#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,26,#egrid_GridLines, #egrid_ResizeColumnsTrue|#egrid_MultiLineText)
;******************************************************************************************
egrid_CreateCellCallback(1, @MyCellCallBack())
egrid_SetHeaderHeight(1, 26)
egrid_SetOptions(1, -1, #Black, 2, -1) ; gadgetnum, header border colour, selection border colour, selection border width, gridline colour
;********************************************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
For b=0 To 99 ; Add 10 rows.
egrid_AddRow(1,-1)
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
Posted: Tue Feb 13, 2007 9:35 pm
by zikitrake

yes!... thank you for the fast reply
Posted: Tue Feb 13, 2007 9:38 pm
by srod
You're welcome.
You can of course switch the cells from #egrid_String to #egrid_StaticString and back again at will in order to switch in and out of 'read only' mode.

Posted: Tue Feb 13, 2007 9:53 pm
by Thorsten1867
I need in the callback the cell text for '#egrid_FormatCell'
to decide, which color I need (Marks: 1-2 green / 5-6 red).
Is this possible?
Posted: Tue Feb 13, 2007 9:57 pm
by srod
Just use egrid_getCellText(#egrid, *cellinfo\column, *cellinfo\row)
Posted: Tue Feb 13, 2007 10:03 pm
by Thorsten1867
Thanks! That's easy. I'm afraid, I thought in the wrong direction.
Posted: Tue Feb 13, 2007 10:06 pm
by srod
Posted: Wed Feb 14, 2007 12:42 am
by zikitrake
Any simple sample to use #WM_LBUTTONDBLCLK in normal PB LOOP?
In my code, the event never occurs on my Egrid gadget
Code: Select all
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
MENU_EVENTOS(EventID, MenuID, GadgetID, WindowID)
Select EventID
Case #WM_LBUTTONDBLCLK
SetWindowTitle(#Window_Principal,"DBLCLICK ON GADGET:" +Str(GadgetID) + " - " + Str(Random(10)))
If GadgetID = #My_Egrid
MessageRequester("hey!", "double click on Egrid")
EndIf
EndSelect
;.....
;.....
ForEver
Posted: Wed Feb 14, 2007 12:58 am
by zikitrake
[AutoAnswer]
replace
by
[/AutoAnswer]
Posted: Wed Feb 14, 2007 12:19 pm
by srod
#WM_LBUTTONDBLCLK works fine here. There's a slight problem in that the second click is sometimes swallowed by the various controls used to edit certain cells etc.