PureCOLOR library : coloring gadgets (and much more)

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

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

DoubleDutch wrote:Is it possible soon? :D
It is :lol:
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 »

Good! :D
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 »

Library update

What's new :
- new function : PureCOLOR_SetMenuItemColors() ; see example below.

Code: Select all

Procedure.l WindowCallBack(WindowId.l, message.l, wParam.l, lParam.l)
  ReturnValue.l = #PB_ProcessPureBasicEvents
  ;
  ReturnValue = PureCOLOR_CallBack(WindowId, message, wParam, lParam, ReturnValue)
  ;
  ProcedureReturn ReturnValue
EndProcedure
;
If OpenWindow(0, 10, 10, 300, 200, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Ownerdraw MenuItems Demo")
  SetWindowCallback(@WindowCallBack())
  If CreateMenu(0, WindowID())
    MenuTitle("   1   ")
    MenuItem(1, "   2   ")
    MenuItem(2, "   3   ")
    OpenSubMenu("   4   ")
    MenuItem(9, "   5   ")
    OpenSubMenu("   6   ")
    MenuItem(10, "   7   ")
    MenuItem(11, "   8   ")
    CloseSubMenu()
    CloseSubMenu()
    MenuItem(3, "   9   ")
    MenuItem(4, "   10  ")
    MenuTitle("   11  ")
    MenuItem(5, "   12  ")
    MenuItem(6, "   13  ")
  EndIf
  PureCOLOR_SetWindowColor(0, RGB(200, 255, 200))
  ; You have to define an owner drawn menu
  PureCOLOR_SetMenuColors(0, #Red, RGB(200, 255, 200), #PureCOLOR_SystemColor, RGB(100, 255, 100))
  ; before you can set special colors for menu items
  PureCOLOR_SetMenuItemColors(0, 7, #Red, RGB(255, 255, 255), #Yellow, #Blue)
  PureCOLOR_SetMenuItemColors(0, 9, #Blue, RGB(255, 255, 255), #Red, #Yellow)
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_Event_CloseWindow
EndIf
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

This library is simply awesome.

Great work.
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 »

Fred should beg to let it be included in the official distribution... :D

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

As I've said before - the guy's a PB genious.

Thanks again for all your contributions.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes
- New function : PureCOLOR_GetCellColor()
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes :
- fixed problem with multiline StringGadget [ viewtopic.php?t=17598 ]
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

I was puzzeled when GetCellColor did not return the expected number (returned $ff000000); then I realized that I had coloured the whole line, not the cell I was inspecting.


A suggestion...
GetRowColor() would solve my problem, or GetCellColor() should always return the colour, even if defined by SetRowColor()

(My need is to flash an already coloured row ending up with the original colour)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

RichardL wrote:I was puzzeled when GetCellColor did not return the expected number (returned $ff000000); then I realized that I had coloured the whole line, not the cell I was inspecting.
The cells colors are not stored the same way if you use SetCellColor() or SetRow/ColumnColor().
RichardL wrote: A suggestion...
GetRowColor() would solve my problem, or GetCellColor() should always return the colour, even if defined by SetRowColor()
Ok, I will add this to GetCellColor().
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

Thanks, I think that would be a tidy solution.

I also note that if a cell is coloured SetRowColor() does not over-ride the cell colour. Was this intentional?

My personal vote would be that if a row was coloured it would overwrite the individual cell colours on that row; but my opinion is very much due to the job in hand... it could well be different next week! A flag maybe?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes :
- changed PureCOLOR_GetCellColor() : get the listicon cell color, set with the PureCOLOR SetCellColor() / SetColumnColor() / SetRowColor() functions.
See previous post.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

RichardL wrote:I also note that if a cell is coloured SetRowColor() does not over-ride the cell colour. Was this intentional?
Yes, it's by design.
See the help file :
The coloring priority is Cells > Columns > Rows.
I had to define a priority. It's the order the coloring functions are called in the callback.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

Thank you... An excellent library just got better.
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

Here is a snip of code from my current project; which tests the feeders used for PCB assembly pick-and-place machines.

Code: Select all

Procedure ReWriteDisplay()             ;- Refresh feeder data to screen
  ColV = $FFFFFF ! $30                                   ; Line background colour value to use  
  SendMessage_(GadgetID(001),#WM_SETREDRAW, #False, 0)   ; Turn off redraw until we have finished
  ClearGadgetItemList(001)                               ; Clear the display
  AddGadgetItem(1,0,"")                                  ; ?
  For n.w = 1 To MaxNumFeeders                           ; Typically 1000 units
    AddGadgetItem(1,n.w,FeederData$(n.w))                ; Put data from array into display gadget
    ColV ! $30                                           ; Toggle the background colour
    PureCOLOR_SetRowColor (001,n.w,  0,ColV)             ; Colour the line
    PureCOLOR_SetCellColor(001,n.w,0,0,ColV)             ; Set the first cell to match... so I can use GetCellColor()
    If FeederFlags(n.w)                                  ; If to be marked as defective...
      PureCOLOR_SetCellColor(001,n.w,0,0,$8080FF)        ; Colour the first cell light red
    EndIf
  Next
  SendMessage_(GadgetID(001),#WM_SETREDRAW, #True, 0)    ; Turn on redraw
  While WindowEvent() : Wend                             ; Allow re-draw
EndProcedure
It works just fine but takes longer and longer to execute.

Disable the PureColor calls = 47mSec as many times as I like
With line and cell colouring I get progressively slower...
203
360
1219
2265
2813
3281
3765
4281

Any suggestions for what I might be doing wrong?
Post Reply