
PureCOLOR library : coloring gadgets (and much more)
Moderator: gnozal
Hello Gnozal,
I'm trying to do a tricky thing but to finish it i need just one more constant for :
- PureCOLOR_SetButtonColor()
- PureCOLOR_SetGadgetColor()
#PureCOLOR_Ignore = #PB_Ignore ; New constant, Means No Change.
Here is the tricky thing i would like to do :
I would like to extends the possibilities of SetGadgetColor() thanks to the PureCOLOR but by keeping the original PureBasic syntax.
PureCOLOR_Patch.pbi
PureCOLOR_Patch_Test.pb
a classic purebasic source, using builtins commands.
should be colored even if those gadgets are not supported by purebasic.
I'm trying to do a tricky thing but to finish it i need just one more constant for :
- PureCOLOR_SetButtonColor()
- PureCOLOR_SetGadgetColor()
#PureCOLOR_Ignore = #PB_Ignore ; New constant, Means No Change.
Here is the tricky thing i would like to do :
I would like to extends the possibilities of SetGadgetColor() thanks to the PureCOLOR but by keeping the original PureBasic syntax.


PureCOLOR_Patch.pbi
Code: Select all
;-
;- Object: PureCOLOR Library for PureBasic 4.0
;- Author: Written by Gnozal
;- Link: http://people.freenet.de/gnozal/
;-
;- Patch v0.1 by flype, July 2006.
;-
#PureCOLOR_Ignore = #PB_Ignore
Enumeration 1 ; #PB_Gadget_xxxColor
#PB_Gadget_FrontColor
#PB_Gadget_BackColor
#PB_Gadget_LineColor
#PB_Gadget_TitleFrontColor
#PB_Gadget_TitleBackColor
#PB_Gadget_GrayTextColor
#PB_Gadget_TextPushedColor ; PureCOLOR_SetButtonColor()
#PB_Gadget_BackPushedColor ; PureCOLOR_SetButtonColor()
EndEnumeration
Procedure.l SetGadgetColorA(gadget.l, type.l, color.l) ; Workaround to avoid unlimited recursive call to the macro SetGadgetColor()
SetGadgetColor(gadget, type, color)
EndProcedure
Procedure.l SetGadgetColorB(gadget.l, type.l, color.l) ; Extends the possibilities of SetGadgetColor()
Select GadgetType(gadget)
Case #PB_GadgetType_Button
; Not supported by PureBasic. Time to use PureCOLOR.
Select type
Case #PB_Gadget_BackColor
PureCOLOR_SetButtonColor(gadget, #PureCOLOR_Ignore, color)
Case #PB_Gadget_FrontColor
PureCOLOR_SetButtonColor(gadget, color, #PureCOLOR_Ignore)
Case #PB_Gadget_TextPushedColor
PureCOLOR_SetButtonColor(gadget, #PureCOLOR_Ignore, #PureCOLOR_Ignore, color)
Case #PB_Gadget_BackPushedColor
PureCOLOR_SetButtonColor(gadget, #PureCOLOR_Ignore, #PureCOLOR_Ignore, #PureCOLOR_Ignore, color)
EndSelect
Case #PB_GadgetType_Panel
; Not supported by PureBasic. Time to use PureCOLOR.
Select type
Case #PB_Gadget_BackColor
PureCOLOR_SetGadgetColor(gadget, #PureCOLOR_Ignore, color)
Case #PB_Gadget_FrontColor
PureCOLOR_SetGadgetColor(gadget, color, #PureCOLOR_Ignore)
EndSelect
Case #PB_GadgetType_IPAddress
; Not supported. Neither PureBasic, Nor PureCOLOR.
Default
; Supported by PureBasic. No need to use PureCOLOR.
SetGadgetColorA(gadget, type, color)
EndSelect
EndProcedure
Macro SetGadgetColor(gadget, type, color) ; Patch PureBasic Built-In command.
SetGadgetColorB(gadget, type, color)
EndMacro
;- EOF
a classic purebasic source, using builtins commands.
should be colored even if those gadgets are not supported by purebasic.
Code: Select all
;XIncludeFile "PureCOLOR_PATCH.pb"
If OpenWindow(0, 0, 0, 320, 240, "SetGadgetColor()", #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
PanelGadget(0, 10, 10, 300, 220)
SetGadgetColor(0, #PB_Gadget_BackColor, $A0F0F0)
AddGadgetItem (0, -1, "Page 1")
ButtonGadget(1, 5, 5, 150, 40, "Exit")
;SetGadgetColor(1, #PB_Gadget_TextPushedColor, #Green)
;SetGadgetColor(1, #PB_Gadget_BackPushedColor, #Blue)
SetGadgetColor(1, #PB_Gadget_FrontColor, #Red)
SetGadgetColor(1, #PB_Gadget_BackColor, #Yellow)
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_Gadget
EndIf
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:
@Flype : very nice idea.
Why not use #PureCOLOR_Ignore = #PureCOLOR_SystemColor ?
And there are the transparent TextGadgets with BackColor = #PureCOLOR_DontSetBackColor ...
Why not use #PureCOLOR_Ignore = #PureCOLOR_SystemColor ?
And there are the transparent TextGadgets with BackColor = #PureCOLOR_DontSetBackColor ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Yes, i know Gnozal for the #PureCOLOR_DontSetBackColor.
But it is not enough. As well, #PureCOLOR_SystemColor is not enough nor adapted.
I would need :
#PureCOLOR_DontSetTextColor ; not implemented
#PureCOLOR_DontSetBackColor ; yet implemented
#PureCOLOR_DontSetTextPushedColor ; not implemented
#PureCOLOR_DontSetBackPushedColor ; not implemented
Or
#PureCOLOR_Ignore,
which is simpler (and shorter) i think. Should be possible.
But it is not enough. As well, #PureCOLOR_SystemColor is not enough nor adapted.
I would need :
#PureCOLOR_DontSetTextColor ; not implemented
#PureCOLOR_DontSetBackColor ; yet implemented
#PureCOLOR_DontSetTextPushedColor ; not implemented
#PureCOLOR_DontSetBackPushedColor ; not implemented
Or
#PureCOLOR_Ignore,
which is simpler (and shorter) i think. Should be possible.
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:
Hmm
PureCOLOR does not work that way : it always expects TextColor and BackColor in the callbacks.
The colors (Text/Back/Brush) are stored at the beginning when you call PureCOLOR_SetGagdetColor().
You could do the following :
If color already set for gadget, Ignore = #PureCOLOR_UseLastColor
If color not already set for gadget, use Ignore = #PureCOLOR_SystemColor
But you have to remember wich colors were set and wich not.
Sorry, not much time now ...
PureCOLOR does not work that way : it always expects TextColor and BackColor in the callbacks.
The colors (Text/Back/Brush) are stored at the beginning when you call PureCOLOR_SetGagdetColor().
You could do the following :
If color already set for gadget, Ignore = #PureCOLOR_UseLastColor
If color not already set for gadget, use Ignore = #PureCOLOR_SystemColor
But you have to remember wich colors were set and wich not.
Sorry, not much time now ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Update (both libs)
- Fixed a small listicon subclassing problem : http://www.purebasic.fr/german/viewtopi ... 2&start=10
- Fixed a small listicon subclassing problem : http://www.purebasic.fr/german/viewtopi ... 2&start=10
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Hi Gnozal,
i found a bug where the Font information on a listicon is lost when i use a callback :

Heres the code for the callback i´m using :
i found a bug where the Font information on a listicon is lost when i use a callback :
Heres the code for the callback i´m using :
Code: Select all
Procedure ColorCallBack(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor.LONG, *BackColor.LONG, *FontID.LONG)
Select GadgetNumber
Case #Fehlerstatistik_LGadget1
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,1)
Select LCase(CellText)
Case "in produktion"
Col=#Orange
Case "ok"
Col=#Gruen
Case "gesperrt"
Col=#Rot
Case "ausschuss"
Col=#Purpur
Case "nacharbeit"
Col=#Mint
Default
Col=#Sys1
EndSelect
If Col<>#Gruen
*BackColor\l=Background_Edit(Col)
EndIf
Case #Ausschuss_LGadget1
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,5)
If LCase(CellText)="nicht zugeordnet"
*BackColor\l=Background_Edit(#Rot)
EndIf
Case #Qualitaetsmanagement_LGadget1
Select CellColumn
Case 0 To 4
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,4)
Select LCase(CellText)
Case "in produktion"
Col=#Orange
Case "ok"
Col=#Gruen
Case "gesperrt"
Col=#Rot
Case "ausschuss"
Col=#Purpur
Case "nacharbeit"
Col=#Mint
Default
Col=#Sys1
EndSelect
*BackColor\l=Background_Edit(Col)
Case 5 To 10
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,CellColumn)
Select LCase(CellText)
Case ""
Col1=#Orange
Case "ok"
Col1=#Gruen
Case "gesperrt"
Col1=#Rot
Case "ausschuss"
Col1=#Purpur
Case "nacharbeit"
Col1=#Mint
EndSelect
*BackColor\l=Background_Edit(Col1)
EndSelect
Case #WDLGadget1
Select CellColumn
Case 0,1,2,3,4,15,16
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,16)
Select LCase(CellText)
Case "in produktion"
Col=#Orange
Case "ok"
Col=#Gruen
Case "gesperrt"
Col=#Rot
Case "ausschuss"
Col=#Purpur
Case "nacharbeit"
Col=#Mint
Default
Col=#Sys1
EndSelect
If Col<Gruen>5
*BackColor\l=Background_Edit(#Rot)
EndIf
Case 7,9,11,13,14
Value=Val(GetGadgetItemText(GadgetNumber,CellRow,CellColumn))
If Value>500
*BackColor\l=Background_Edit(#Rot)
EndIf
EndSelect
Case #IDNut_LGadget_IDNut
;*FontID\l=FontID2 ; Workaround for Bug in PureColor Library 16.7.2006 19:33
CellText.s=GetGadgetItemText(GadgetNumber,CellRow,2)
Select LCase(CellText)
Case "in produktion"
Col=#Orange
Case "ok"
Col=#Gruen
Case "gesperrt"
Col=#Rot
Case "ausschuss"
Col=#Purpur
Case "nacharbeit"
Col=#Mint
Default
Col=#Sys1
EndSelect
*BackColor\l=Background_Edit(Col)
EndSelect
EndProcedure
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
@ABBKlaus :
It's not a bug, it's how it is planned to work : maybe it's a bad design
If you use the Cell Color Callback, the default font is the default GUI font [ GetStockObject_(#ANSI_VAR_FONT) ] and not the gadget font, since you are supposed to control Color/BackColor/Font for each cell.
Maybe I shoud change the default font to GetGadgetFont(#ListIcon) ?
It's not a bug, it's how it is planned to work : maybe it's a bad design

If you use the Cell Color Callback, the default font is the default GUI font [ GetStockObject_(#ANSI_VAR_FONT) ] and not the gadget font, since you are supposed to control Color/BackColor/Font for each cell.
Maybe I shoud change the default font to GetGadgetFont(#ListIcon) ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Thanks for the reply Gnozal.
I only wanted to change the backcolor !
If this is the standard behavior it should be in the manual
i now use your workaround :
Klaus
I only wanted to change the backcolor !
If this is the standard behavior it should be in the manual

i now use your workaround :
Code: Select all
If IsGadget(GadgetNumber)
*FontID\l=GetGadgetFont(GadgetNumber)
EndIf
@gnozal,
I would ask you if is possible change colors (front & back) of then combogadget's edit control too ( i've tried with the last version of your library (v12.20)) .
I've used the message #WM_CTLCOLOREDIT to do it for now , but i think is useful and logic if you'll add in you SUPER library!
Thanks in advance.
I would ask you if is possible change colors (front & back) of then combogadget's edit control too ( i've tried with the last version of your library (v12.20)) .
I've used the message #WM_CTLCOLOREDIT to do it for now , but i think is useful and logic if you'll add in you SUPER library!
Thanks in advance.
PB Registered User, Egrid Registered User
Win7 x64 Ultimate, 4,00 Gb Mem, Ati Radeon HD4600 Series, Realtek High Definition Audio Integrated
Win7 x64 Ultimate, 4,00 Gb Mem, Ati Radeon HD4600 Series, Realtek High Definition Audio Integrated
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Ok, for the next version.magicjo wrote:@gnozal,
I would ask you if is possible change colors (front & back) of then combogadget's edit control too ( i've tried with the last version of your library (v12.20)) .
I've used the message #WM_CTLCOLOREDIT to do it for now , but i think is useful and logic if you'll add in you SUPER library!
Thanks in advance.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).