PureCOLOR library : coloring gadgets (and much more)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

...I use a Cellcallback in my app.
I have no problems with all other gadgets colored with PureColor.

Here`s a snippet of the callback:

Code: Select all

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

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

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

  Select uMsg
    Case #egrid_FormatCell
      If *cellinfo\row=-1 ;Custom header.
        If *cellinfo\column>=0 And *cellinfo\column<=29
          *cellinfo\forecolour = #Black
          *cellinfo\backcolour = #Red
          *cellinfo\borderstyles=#egrid_TopThickSolid|#egrid_BottomThickSolid 
      ;EndIf  
        Else
          *cellinfo\backcolour=#White
        EndIf 
      EndIf 
      If Not (*cellinfo\row)%2
        If *cellinfo\column>=0 And *cellinfo\column<=17
          *cellinfo\backcolour=#Red
        Else
          *cellinfo\backcolour=#White
        EndIf 
      EndIf 
  
        Default 
      result = #True                       ;This accounts for all messages we have decided not to process.
  EndSelect
  ProcedureReturn result
EndProcedure

If OpenWindow(0,0,0,640,300,"EsGRID demo 1.",#PB_Window_SystemMenu|#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_CreateCellCallback(1, @MyCellCallBack())
  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.
  
  OptionGadget(4, 4, 4, 145, 20, "Test 1")
  PureCOLOR_SetGadgetColor(4, RGB(0,50,50), RGB(220,220,220)) ; without this -> no problem
  
 Repeat
    EventID = WaitWindowEvent()
    
    Select EventID
      
      Case #PB_Event_Gadget
    EndSelect
  Until EventID = #PB_Event_CloseWindow
  
EndIf
  
End


...the color will be shown, when a cell has been selected :(
PureBasic for Windows
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry, I understand the problem now. I don't use PureColor so cannot run your code.

Switching to pm.
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 »

Okay, I downloaded PureCOLOR and ran your example.

The problem is that if PureCOLOR subclasses the parent of the EsGRID after EsGRID does, then PureCOLOR is being a little naughty and not passing some notifications back to my subclass proc! :wink: Specifically it is not passing lots of instances of #NM_CUSTOMDRAW messages which EsGRID relies upon.

Either we bully Gnozal into ensuring that these notifications are passed back in the event that the underlying control has not been registered with PureCOLOR, or we, by means of a quick fix, ensure that EsGRID gets to subclass the parent after PureCOLOR does :

Code: Select all

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

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

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

  Select uMsg 
    Case #egrid_FormatCell 
      If *cellinfo\row=-1 ;Custom header. 
        If *cellinfo\column>=0 And *cellinfo\column<=29 
          *cellinfo\forecolour = #Black 
          *cellinfo\backcolour = #Red 
          *cellinfo\borderstyles=#egrid_TopThickSolid|#egrid_BottomThickSolid 
      ;EndIf  
        Else 
          *cellinfo\backcolour=#White 
        EndIf 
      EndIf 
      If Not (*cellinfo\row)%2 
        If *cellinfo\column>=0 And *cellinfo\column<=17 
          *cellinfo\backcolour=#Red 
        Else 
          *cellinfo\backcolour=#White 
        EndIf 
      EndIf 
  
        Default 
      result = #True                       ;This accounts for all messages we have decided not to process. 
  EndSelect 
  ProcedureReturn result 
EndProcedure 

If OpenWindow(0,0,0,640,300,"EsGRID demo 1.",#PB_Window_SystemMenu|#PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
    
  OptionGadget(4, 4, 4, 145, 20, "Test 1") 
  PureCOLOR_SetGadgetColor(4, #Red, RGB(220,220,220)) ; without this -> no problem 

  egrid_CreateGrid(1, WindowWidth(0)/4, WindowHeight(0)/8, WindowWidth(0)/2, WindowHeight(0)/2,42,0, #egrid_GridLines|#egrid_ResizeColumnsTrue|#egrid_MultiLineText) 
  egrid_CreateCellCallback(1, @MyCellCallBack()) 
  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. 
  
  
 Repeat 
    EventID = WaitWindowEvent() 
    
    Select EventID 
      
      Case #PB_Event_Gadget 
    EndSelect 
  Until EventID = #PB_Event_CloseWindow 
  
EndIf 
  
End
I may look like a mule, but I'm not a complete ass.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Post by Marco2007 »

Thanx! I can live with that :D
PureBasic for Windows
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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!!!
You have to use a workaround (setting the #LVS_EX_GRIDLINES style manually), because since PB4.20 beta gadget library ownerdraw is used for the gridlines (thanks Fred for the info).

Code: Select all

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) 
      ;
      ; workaround, because since PB4.20 beta gadget library PB uses ownerdraw for the gridlines
      #LVS_EX_GRIDLINES = 1
      SendMessage_(GadgetID(#ListIcon_0), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_GRIDLINES, #LVS_EX_GRIDLINES)
      ;
      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) 
      ;
      PureCOLOR_SetGadgetColorEx(#ListIcon_0, #PureCOLOR_SystemColor,#PureCOLOR_SystemColor, RGB(255, 255, 223), #PureCOLOR_LV_AlternateColors)
      
    EndIf 
  EndIf 
EndProcedure 

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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Gnozal: I realise that you have previously said that your going to wait until 4.30 final, but with the final PB4.30 almost with us (b5 or RC1 is here now) - I don't think there will be anything left that could 'break' your libs. Do you think you could do an early release?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

DoubleDutch wrote:I don't think there will be anything left that could 'break' your libs.
Only Fre[d|ak] knows.
DoubleDutch wrote:Do you think you could do an early release?
Will see.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PHP
User
User
Posts: 65
Joined: Sat Sep 10, 2005 5:38 pm

Post by PHP »

gnozal please update the lib! the final is out and many of my programs don't work anymore :(
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

The libs are updated. Check out the site. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Yes, I was away for 1 week, but I recompiled all libs with PB4.30 beta 5 before leaving.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
iostream
User
User
Posts: 12
Joined: Thu Jul 31, 2008 12:36 pm
Location: Germany

Post by iostream »

I think i found a bug...

When I use a window-menu and a popup-menu, they don't work together:
The 1st menutitle of the window-menu appears in the popup-menu.
This effect only appears when I create the popup first and the window-menu later.

Code: Select all

Enumeration
   #M
   #MP
EndEnumeration

If OpenWindow(0, 0, 0, 330, 220, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CreatePopupMenu(#MP)
       PureCOLOR_MenuItem(#MP, 1, "popup 1")
       PureCOLOR_MenuItem(#MP, 2, "popup 2")
       MenuBar()
       PureCOLOR_MenuItem(#MP, 3, "popup 3")
    PureCOLOR_ActivateColoredPopUpMenu(#MP, 0)
    PureCOLOR_SetPopUpOfficeStyle(#MP, 0)

    CreateMenu(#M, WindowID(0))
    MenuTitle("Datei")
       PureCOLOR_MenuItem(#M, 4, "menu 1")
       PureCOLOR_MenuItem(#M, 5, "menu 2")
       MenuBar()
       PureCOLOR_MenuItem(#M, 6, "menu 3")
    PureCOLOR_ActivateColoredMenu(#M)
    PureCOLOR_SetOfficeStyle(#M)
   
    Repeat
      event = WaitWindowEvent()
          Select event
               Case #WM_RBUTTONUP
                DisplayPopupMenu(#MP, WindowID(0))
             Case #PB_Event_CloseWindow
                Break
          EndSelect
     ForEver
EndIf

End
If i create the window-menu first and the popup later, all menutitles in the window-menu contains weird signs.

Greetings
iostream
Last edited by iostream on Tue Jun 09, 2009 10:33 am, edited 1 time in total.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

iostream wrote:When I use a window-menu and a popup-menu, they don't work together:
The 1st menutitle of the window-menu appears in the popup-menu.
This effect only appears when I create the popup first and the window-menu later.
Sorry, this is currently a limitation of PureCOLOR ; you can't have a menu and a popup menu with the same parent window.
I may change this when I have some time.

You could use this workaround :

Code: Select all

Enumeration 
  #M 
  #MP 
EndEnumeration 

If OpenWindow(1, 0, 0, 0, 0, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered |#PB_Window_Invisible) 
  CreatePopupMenu(#MP) 
  PureCOLOR_MenuItem(#MP, 1, "popup 1") 
  PureCOLOR_MenuItem(#MP, 2, "popup 2") 
  MenuBar() 
  PureCOLOR_MenuItem(#MP, 3, "popup 3") 
  PureCOLOR_ActivateColoredPopUpMenu(#MP, 1) 
  PureCOLOR_SetPopUpOfficeStyle(#MP, 1) 
EndIf

If OpenWindow(0, 0, 0, 330, 220, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  
  CreateMenu(#M, WindowID(0)) 
  MenuTitle("Datei") 
  PureCOLOR_MenuItem(#M, 4, "menu 1") 
  PureCOLOR_MenuItem(#M, 5, "menu 2") 
  MenuBar() 
  PureCOLOR_MenuItem(#M, 6, "menu 3") 
  PureCOLOR_ActivateColoredMenu(#M) 
  PureCOLOR_SetOfficeStyle(#M) 
  
  Repeat 
    event = WaitWindowEvent() 
    Select event 
      Case  #PB_Event_Menu      
        Debug EventMenu() 
      Case #WM_RBUTTONUP 
        DisplayPopupMenu(1, WindowID(0)) 
      Case #PB_Event_CloseWindow 
        Break 
    EndSelect 
  ForEver 
EndIf 

End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
iostream
User
User
Posts: 12
Joined: Thu Jul 31, 2008 12:36 pm
Location: Germany

Post by iostream »

Sorry, this is currently a limitation of PureCOLOR ; you can't have a menu and a popup menu with the same parent window.
Thanks for the info, your workaround works fine :wink:
User_Russian
Addict
Addict
Posts: 1519
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Post by User_Russian »

iostream wrote:I think i found a bug...

When I use a window-menu and a popup-menu, they don't work together:
The 1st menutitle of the window-menu appears in the popup-menu.
This effect only appears when I create the popup first and the window-menu later.
Use library XP_Menu_Lib http://www.purebasic.fr/english/viewtop ... sc&start=0
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

User_Russian wrote:Use library XP_Menu_Lib http://www.purebasic.fr/english/viewtop ... sc&start=0
Thanks for advertising, unfortunately XP_Menu_Lib doesn't work on all Windows platforms, as I already reported.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply