PureCOLOR library : coloring gadgets (and much more)
Moderator: gnozal
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Update
Changes :
- fixed subclassing problem reported here : http://forums.purebasic.com/german/viewtopic.php?t=6578
Changes :
- fixed subclassing problem reported here : http://forums.purebasic.com/german/viewtopic.php?t=6578
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
very thank you for your suggestion about the cell callback - exactly what i need.
and of course for this fix (which i needed too).

No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
hello, found a strange bug, not easy to isolate :
1/ Double click on a line into the ListIconGadget.
2/ The InputRequester() display what it should display.
3/ Now, uncomment the line 26 [PureCOLOR_SetCellColorCallback(0,@myCallback())]
4/ Redo the test, and have a funny but surprising result.
But if you do this, it does the job !?#%$? Strange, no ?
Good Luck, Gnozal 
Code: Select all
Procedure.l myCallback(gID.l,row.l,column.l,*TextColor.l,*BackColor.l)
Select gID
Case 0
Select column
Case 0
PokeL(*TextColor,$AA4444)
EndSelect
EndSelect
EndProcedure
If OpenWindow(0,0,0,640,480,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Bug()")
If CreateGadgetList(WindowID())
ListIconGadget(0,5,5,630,470,"A",120,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"B",120)
AddGadgetColumn(0,2,"C",120)
AddGadgetColumn(0,3,"D",120)
For i=0 To 40
AddGadgetItem(0,i,"A"+Str(i)+#LF$+"B"+Str(i)+#LF$+"C"+Str(i)+#LF$+"D"+Str(i))
Next
EndIf
;PureCOLOR_SetCellColorCallback(0,@myCallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadgetID()
Case 0
Select EventType()
Case #PB_EventType_LeftDoubleClick
position = GetGadgetState(0)
If position <> -1
InputRequester("","",GetGadgetItemText(0,position,3))
EndIf
EndSelect
EndSelect
EndSelect
ForEver
EndIf
2/ The InputRequester() display what it should display.
3/ Now, uncomment the line 26 [PureCOLOR_SetCellColorCallback(0,@myCallback())]
4/ Redo the test, and have a funny but surprising result.
But if you do this, it does the job !?#%$? Strange, no ?
Code: Select all
value$ = GetGadgetItemText(0,position,3)
InputRequester("","",value$)

No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
And by the way, do you think it is possible to implement a new parameter to change the font format of a specific cell ? It could be usefull...
Code: Select all
Procedure.l myCallback(gID.l,row.l,column.l,*TextColor.l,*BackColor.l,*FontID.l)
EndProcedure
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Strange indeed.Flype wrote:hello, found a strange bug, not easy to isolate :
Some facts :
- If you replace 'InputRequester("","",GetGadgetItemText(0,Position,3))' by 'MessageRequester("", GetGadgetItemText(0,Position,3))', there is no bug.
Code: Select all
; bug
InputRequester("","",GetGadgetItemText(0,Position,3))
Code: Select all
; no bug !
MessageRequester("", GetGadgetItemText(0,Position,3))
Code: Select all
; no bug !!
InputRequester("","",GetGadgetItemText(0,Position,3))
MessageRequester("", GetGadgetItemText(0,Position,3))
=> It is because of the window subclassing, but why ? And why only the InputRequester ??
It seems to be a Purebasic bug !
I can reproduce it without my lib but with subclassing :
Code: Select all
Procedure.s GetGadgetClass(hGadget.l)
Protected Class.s
Class = Space(255)
GetClassName_(hGadget, @Class, 254)
ProcedureReturn Class
EndProcedure
Procedure.l myCallback(WindowID, message, wParam, lParam)
Shared OldCallback
Result = CallWindowProc_(OldCallback, WindowID, message, wParam, lParam)
b$ = GetGadgetClass(WindowID)
ProcedureReturn Result
EndProcedure
If OpenWindow(0,0,0,640,480,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Bug()")
If CreateGadgetList(WindowID())
ListIconGadget(0,5,5,630,470,"A",120,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"B",120)
AddGadgetColumn(0,2,"C",120)
AddGadgetColumn(0,3,"D",120)
For i=0 To 40
AddGadgetItem(0,i,"A"+Str(i)+#LF$+"B"+Str(i)+#LF$+"C"+Str(i)+#LF$+"D"+Str(i))
Next
EndIf
OldCallback = SetWindowLong_(WindowID(0), #GWL_WNDPROC, @myCallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadgetID()
Case 0
Select EventType()
Case #PB_EventType_LeftDoubleClick
Position = GetGadgetState(0)
If Position <> -1
InputRequester("","",GetGadgetItemText(0,Position,3)) ; <=== the bug : displays the window class !!!!
EndIf
EndSelect
EndSelect
EndSelect
ForEver
EndIf
It could be usefull, yes... Will see ...Flype wrote:And by the way, do you think it is possible to implement a new parameter to change the font format of a specific cell ? It could be usefull...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ok, you think it could be a purebasic bug, not sure but it could be.
i was wondering about that, i will investigate a bit more and let you informed.
but, first, you should post your code (subclassing without your lib) in the bug section. this bug can't stay unsolved.
i was wondering about that, i will investigate a bit more and let you informed.
but, first, you should post your code (subclassing without your lib) in the bug section. this bug can't stay unsolved.

No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I had a similar problem with input requester and getgadgetitemtext, it went away if it got the text before the inputrequester.
eg
inputrequester("","",getgadgetitemtext..... <--- bug - seemed to show something from the clipboard!!!
a$=getgadgetitemtext....
inputrequester("","",a$) <--- worked - the proper text displayed
it may not be to do with subclassing, but something else?
edit:
I seem to remember random things happening with left(...) as the 3rd parameter of input requester too. I think it went when I simplified things as above. Maybe the bug is related to setting the default item???
I didn't mention it on the forum because it was one of the times the forum wasn't working properly.
eg
inputrequester("","",getgadgetitemtext..... <--- bug - seemed to show something from the clipboard!!!
a$=getgadgetitemtext....
inputrequester("","",a$) <--- worked - the proper text displayed
it may not be to do with subclassing, but something else?
edit:
I seem to remember random things happening with left(...) as the 3rd parameter of input requester too. I think it went when I simplified things as above. Maybe the bug is related to setting the default item???
I didn't mention it on the forum because it was one of the times the forum wasn't working properly.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Update
Changes :
- new parameter to change the font for a specific listicon cell
Changes :
- new parameter to change the font for a specific listicon cell
Code: Select all
FontID = LoadFont(0, "Courier New", 9, #PB_Font_Bold)
;
Procedure MyCellColorCallback(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor.LONG, *BackColor.LONG, *FontID.LONG)
Shared FontID
If GadgetNumber = 1
CellText.s = GetGadgetItemText(GadgetNumber, CellRow, CellColumn)
Debug Str(CellRow) + ":" + Str(CellColumn) + ">" + CellText
Select CellText
Case "Red"
*TextColor\l = #Red
Debug "-> Red"
Case "Blue"
*BackColor\l = #Blue
*TextColor\l = #White
Debug "-> Blue"
Case "Green"
*TextColor\l = #Green
Debug "-> Green"
Default
*FontID\l = FontID
Debug "-> Font"
EndSelect
EndIf
EndProcedure
; Create Window
OpenWindow(0, 100, 300, 400, 200, #PB_Window_SystemMenu, "PureCOLOR test : cell callback demo")
If CreateGadgetList(WindowID())
ListIconGadget(1, 1, 1, 300, 160, "0", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
;
AddGadgetColumn(1, 1, "1", 100)
AddGadgetColumn(1, 2, "2", 100)
AddGadgetItem(1, -1, "0:0" + Chr(10) + "0:1" + Chr(10) + "Red")
AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
AddGadgetItem(1, -1, "Blue" + Chr(10) + "Green" + Chr(10) + "2:2")
AddGadgetItem(1, -1, "3:0" + Chr(10) + "Red" + Chr(10) + "3:2")
AddGadgetItem(1, -1, "Red" + Chr(10) + "4:1" + Chr(10) + "Red")
AddGadgetItem(1, -1, "Green" + Chr(10) + "Blue" + Chr(10) + "5:2")
AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
AddGadgetItem(1, -1, "Red" + Chr(10) + "Blue" + Chr(10) + "7:2")
EndIf
PureCOLOR_SetCellColorCallback(0, @MyCellColorCallback())
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventCloseWindow
Break
EndIf
ForEver
;
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Now we can use wingdings to add some wierd stuff to a particular cell... 
Anyone know if all 3 wingdings are with all versions of windows?

Anyone know if all 3 wingdings are with all versions of windows?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
What 3 ?DoubleDutch wrote:Anyone know if all 3 wingdings are with all versions of windows?
I only see one wingding.ttf [WinNT4 / Win98SE]
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).