Page 27 of 35

Posted: Tue Jun 24, 2008 5:42 pm
by gnozal
Num3 wrote:PureColor is now bugged with the updated Listicongadgets!

Code: Select all

PureCOLOR_SetGadgetColorEx(#Gadget_main_listtrab, #PureCOLOR_SystemColor,#PureCOLOR_SystemColor, RGB(255, 255, 223), #PureCOLOR_LV_AlternateColors)
Disables gridlines!!!
Confirmed with the gadget library from http://www.purebasic.com/beta/windows/.
But as it's a beta lib and it worked from PB3.9x to PB4.20, how to be sure that :
1. It's not a PB bug ?
2. It will remain in PB4.21 final ?

PureCOLOR simply uses #NM_CUSTOMDRAW to color the rows, and it does no use the gadget item data.
So it looks like a PB bug to me (or the PB ListIcon just became a little more less 'API' compatible) :

Code: Select all

#CDDS_SUBITEMPREPAINT = #CDDS_SUBITEM | #CDDS_ITEMPREPAINT
Procedure.l CallBack(WindowId.l, message.l , wParam.l, lParam.l)
  Protected *LVCDHeader.NMLVCUSTOMDRAW
  Protected Result.l
  ;
  Result = #PB_ProcessPureBasicEvents
  If message = #WM_NOTIFY
    *LVCDHeader = lParam
    If *LVCDHeader\nmcd\hdr\code = #NM_CUSTOMDRAW
      Select *LVCDHeader\nmcd\dwDrawStage
        Case #CDDS_PREPAINT
          Result = #CDRF_NOTIFYITEMDRAW
        Case #CDDS_ITEMPREPAINT
          Result = #CDRF_NOTIFYSUBITEMDRAW
        Case #CDDS_SUBITEMPREPAINT
            If *LVCDHeader\nmcd\dwItemSpec & 1
              *LVCDHeader\clrTextBk = #White
            Else
              *LVCDHeader\clrTextBk = #Yellow
            EndIf
          Result = #CDRF_NEWFONT
      EndSelect
    EndIf
  EndIf
  ProcedureReturn Result 
EndProcedure
Enumeration
  #Window_0
EndEnumeration
Enumeration
  #ListIcon_0
EndEnumeration
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 400, 215, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ListIconGadget(#ListIcon_0, 16, 17, 375, 191, "Gadget_0", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
      AddGadgetColumn(#ListIcon_0, 1, "Column #2", 100)
      AddGadgetColumn(#ListIcon_0, 2, "Column #3", 100)
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      AddGadgetItem(#ListIcon_0, -1, "x" + Chr(10) + "x" + Chr(10) + "x")
      SendMessage_(GadgetID(#ListIcon_0), #LVM_SETCOLUMNWIDTH, 0, #LVSCW_AUTOSIZE_USEHEADER)
      SendMessage_(GadgetID(#ListIcon_0), #LVM_SETCOLUMNWIDTH, 1, #LVSCW_AUTOSIZE_USEHEADER)
      SendMessage_(GadgetID(#ListIcon_0), #LVM_SETCOLUMNWIDTH, 2, #LVSCW_AUTOSIZE_USEHEADER)
    EndIf
  EndIf
EndProcedure

SetWindowCallback(@CallBack())
OpenWindow_Window_0()

Repeat
  Event = WaitWindowEvent()
  Select Event
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver

Posted: Tue Jun 24, 2008 5:57 pm
by gnozal
c4s wrote:A bug I realized in the PB 4.20 version (PC 14.03):
I give a ButtonGadget a color with PureCOLOR_SetButtonColor() (with the
first BackColor option). Then I disable the button and it should be gray but it
is white now (in disabled state). After that I enable the button again and now
the ButtonGadget should have the color I set before but it's sometimes gray
or white and definitly not the color I want ...

The PB 4.10 worked totally correct... (disabled color = gray; enabling gives
Works as expected here

Code: Select all

PureCOLOR_SetButtonColor(4, RGB(255,0,0), RGB(0,255,0))
DisableGadget(4, #True) ; -> gray
DisableGadget(4, #False) ; -> original colors 
Do you have some code ?

Posted: Tue Jun 24, 2008 8:24 pm
by c4s
gnozal wrote:Do you have some code ?
Sure:

Code: Select all

Enumeration 
	#Window
	#Button
	#OnOff
	#ChangeColor
EndEnumeration



If OpenWindow(#Window, 0, 0, 100, 160, "PureCOLOR test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(#Window))
	ButtonGadget(#Button, 10, 10, 80, 80, "BUTTON")
	 PureCOLOR_SetButtonColor(#Button, $FF00, $FF00FF)
	CheckBoxGadget(#OnOff, 10, 100, 80, 20, "on / off")
	ButtonGadget(#ChangeColor, 10, 130, 80, 20, "change color")
EndIf


Repeat
	Select WaitWindowEvent()
		Case #PB_Event_Gadget
			Select EventGadget()
				Case #OnOff
					If OnOff = #True
						OnOff = #False
					Else
						OnOff = #True
					EndIf
					DisableGadget(#Button, OnOff)
				Case #ChangeColor
					PureCOLOR_SetButtonColor(#Button, Random($FFFFFF), Random($FFFFFF))
			EndSelect
		Case #PB_Event_CloseWindow
			End
	EndSelect
ForEver
If I change the color in "disabled mode" everything works fine otherwise
the button is first white with black font color (system standard ?!) and
when I push it's ok again...

Posted: Tue Jun 24, 2008 9:51 pm
by ABBKlaus
Hi Gnozal,

the Unicodesubsystem versions of PureColor are crashing.

- PureLibraries - works OK -
CRC32 : ac36cd5c76c8cd0c8761f97e9ec9fd5f *PureCOLOR
- UserLibThreadSafe - works OK -
CRC32 : 01538f3338f57b21aa1184254364b622 *PureCOLOR
- UserLibUnicode - crash -
CRC32 : 2c2d25e4f348a0a9a21d51682bf9556d *PureCOLOR
- UserLibUnicodeThreadSafe - crash -
CRC32 : da2b0bf4a1071779f048e7ebde7e18f8 *PureCOLOR

i tested it on at least 3 different PC´s (Windows XP Pro. SP2+SP3)
All PB-beta libs installed / Clean installation.

Checkboxes and LibrarySubsystem/s are set correctly !

Here´s the example i used to test :

Code: Select all

; --------------------------------------------------------
;
;             PureCOLOR library test file 1
;
; --------------------------------------------------------
;
; Create Window
OpenWindow(0, 100, 300, 400, 200, "PureCOLOR test", #PB_Window_SystemMenu) 
If CreateGadgetList(WindowID(0)) 
  StringGadget(1, 10, 10, 90, 20, "StringGadget 1")
  ListIconGadget(2, 10, 40, 150, 100, "", 146, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
  AddGadgetItem(2, -1, "ListIconGadget 2-1")
  AddGadgetItem(2, -1, "ListIconGadget 2-2")
  AddGadgetItem(2, -1, "ListIconGadget 2-3")
  AddGadgetItem(2, -1, "ListIconGadget 2-4")
  AddGadgetItem(2, -1, "ListIconGadget 2-5")
  TextGadget(3, 10, 160, 300, 30, "TextGadget 3", #PB_Text_Center)
  ButtonGadget(4, 200, 10, 80, 20, "Button 4")
  ComboBoxGadget(5, 295, 10, 100, 100)
  AddGadgetItem(5, -1, "ComboBox 5-1")
  AddGadgetItem(5, -1, "ComboBox 5-2")
  SetGadgetState(5, 0)
  CheckBoxGadget(6, 110, 10, 80, 20, "CheckBox 6")
  ListViewGadget(7, 160, 40, 150, 100, #PB_ListIcon_GridLines)
  AddGadgetItem(7, -1, "ListViewGadget 7-1")
  AddGadgetItem(7, -1, "ListViewGadget 7-2")
  AddGadgetItem(7, -1, "ListViewGadget 7-3")
EndIf
; Gadget colors
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), -1)
PureCOLOR_SetGadgetColorEx(2, RGB(0,0,0), RGB(255, 255, 255), RGB(255, 255, 223), #PureCOLOR_LV_AlternateColors)
PureCOLOR_SetGadgetColor(3, RGB(255,0,0), #PureCOLOR_DontSetBackColor)
PureCOLOR_SetButtonColor(4, RGB(255,0,0), RGB(0,255,0))
PureCOLOR_SetGadgetColor(5, RGB(255,0,0), RGB(255,255,0))
PureCOLOR_SetGadgetColor(6, RGB(255,127,0), #PureCOLOR_DontSetBackColor)
PureCOLOR_SetGadgetColor(7, RGB(255,0,0), RGB(100,100,0))
PureCOLOR_SetGadgetColorEx(2, RGB(255,0,0), RGB(0,255,0), 0, #PureCOLOR_LTV_SelectedItem)
PureCOLOR_SetColumnHeaderColor(2, 0, #PureCOLOR_SystemColor, RGB(249, 248, 158))
; Window color
PureCOLOR_SetWindowColor(0, RGB(249, 248, 158))
;
Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow 
;
End
; jaPBe Version=3.7.12.680
; Build=0
; FirstLine=0
; CursorPosition=12
; ExecutableFormat=Windows
; DontSaveDeclare
Regards Klaus

Posted: Thu Jun 26, 2008 2:22 pm
by gnozal
ABBKlaus wrote:Hi Gnozal,
the Unicodesubsystem versions of PureColor are crashing.
Cannot test unicode right now, sorry (with Win98SE [only available OS here in holidays]).
Does unicode also crash with PB4.20 final _without_ beta gadget lib ?

Posted: Thu Jun 26, 2008 2:43 pm
by gnozal
c4s wrote:
gnozal wrote:Do you have some code ?
Sure: ...
If I change the color in "disabled mode" everything works fine otherwise
the button is first white with black font color (system standard ?!) and
when I push it's ok again...
Thanks.

Posted: Thu Jun 26, 2008 3:10 pm
by gnozal
Update (All PB versions)

Changes :
- fixed disabled button issue posted by c4s

Posted: Thu Jun 26, 2008 5:17 pm
by c4s
gnozal wrote:fixed disabled button issue posted by c4s
Thank you!


edit:
Sorry, I realized that it doesn't work with my example here. I still have to
push the button to show the color change (when I changed the color while
the button is disabled). Because now after enabling the button there is no
text visible (or it has no color (not even black)).
Hopefully you know were the bug is and what's to do...

Posted: Thu Jun 26, 2008 9:10 pm
by ABBKlaus
Gnozal wrote:Does unicode also crash with PB4.20 final _without_ beta gadget lib ?
Yes it does. Both libs crash with PureColor :

CRC32 old Gadget lib : 2ea5678f757026df0df3b05ad14d7de0 *Gadget
CRC32 new Gadget lib : fe261503f74ebc54391ca87a2920e3da *Gadget

Posted: Sat Jun 28, 2008 2:13 pm
by gnozal
c4s wrote:edit:
Sorry, I realized that it doesn't work with my example here. I still have to
push the button to show the color change (when I changed the color while
the button is disabled). Because now after enabling the button there is no
text visible (or it has no color (not even black)).
Hopefully you know were the bug is and what's to do...
Works here (with your example) using Win98SE.
I will test it on NT4/XP when I'm back from holidays.

Posted: Mon Jun 30, 2008 11:51 am
by gnozal
Update

Changes :
- finally (?) fixed disabled button issue posted by c4s (All PB versions)
- fixed crash in unicode mode on XP/Vista systems posted by ABBKlaus (PB4.xx versions)

Posted: Mon Jun 30, 2008 3:43 pm
by c4s
Great, it Seems to work now - thank you!

Posted: Tue Jul 01, 2008 11:22 am
by ABBKlaus
Seems to work fine :D
Merci beaucoup

Posted: Sun Jul 06, 2008 4:01 pm
by Marco2007
Hi Gnozal,

well I don`t know, if it`s PureColor or Esgrid.
PureCOLOR_SetGadgetColor with OptionGadgets doesn`t work with Esgrid. No Gridlines, Colors in the Grid,....

Here`s a short Example (from Esgrid), but with OptionGadget.

Code: Select all

IncludePath "..\Source\"
  XIncludeFile "EsGRID.pbi"
IncludePath ""

Enumeration
  #head1
  #head2
  #main
EndEnumeration
LoadFont(#main, "Arial", 30)

If OpenWindow(0,0,0,640,300,"EsGRID demo 1.",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    
  egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,42,0, #egrid_GridLines|#egrid_ResizeColumnsTrue|#egrid_MultiLineText)
  egrid_SetHeaderHeight(1, 42)
  egrid_SetOption(1, #egrid_SelectionBorderWidth, 2)
  For b=0 To 49 ;50 columns. 
    egrid_AddColumn(1,b,"Col " + Str(b),100)
  Next
  egrid_AddRows(1,-1, 100) ;Add 100 rows.
  
  ContainerGadget(3, 10, 10, 160, 110)
  OptionGadget(4, 4, 4, 145, 20, "Test 1")
  CloseGadgetList()
  PureCOLOR_SetGadgetColor(4, RGB(0,50,50), RGB(220,220,220))
  
 Repeat
    EventID = WaitWindowEvent()
    Select EventID
      
      Case #PB_Event_Gadget
    EndSelect
  Until EventID = #PB_Event_CloseWindow
  
EndIf
End
lg
Marco

I will send Srod a PM...

Posted: Sun Jul 06, 2008 8:13 pm
by srod
Marco,

I would say that there is no chance of PureColor working with EsGRID as EsGRID handles all of the painting of individual cells and gridlines etc.

If you wish to set cell colors etc. you must use a CellCallback with EsGRID.