It isDoubleDutch wrote:Is it possible soon?

Moderator: gnozal
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
The cells colors are not stored the same way if you use SetCellColor() or SetRow/ColumnColor().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.
Ok, I will add this to GetCellColor().RichardL wrote: A suggestion...
GetRowColor() would solve my problem, or GetCellColor() should always return the colour, even if defined by SetRowColor()
Yes, it's by design.RichardL wrote:I also note that if a cell is coloured SetRowColor() does not over-ride the cell colour. Was this intentional?
I had to define a priority. It's the order the coloring functions are called in the callback.The coloring priority is Cells > Columns > Rows.
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