Page 16 of 35

Posted: Mon Jul 03, 2006 1:53 pm
by Inf0Byt3
That did it, I was using -1 as backcolor but now, using #PureCOLOR_DontSetBackColor the results are exactly how I wanted. Thank you :D!

Posted: Tue Jul 04, 2006 6:43 pm
by Beach
Just found this today which will help me on a new project I am working on...

Freakin awesome Gnozal!!

Posted: Mon Jul 10, 2006 10:28 pm
by Flype
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. :? :D

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

PureCOLOR_Patch_Test.pb

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


Posted: Tue Jul 11, 2006 7:37 am
by gnozal
@Flype : very nice idea.
Why not use #PureCOLOR_Ignore = #PureCOLOR_SystemColor ?

And there are the transparent TextGadgets with BackColor = #PureCOLOR_DontSetBackColor ...

Posted: Tue Jul 11, 2006 8:15 am
by Flype
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.

Posted: Tue Jul 11, 2006 10:54 am
by gnozal
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 ...

Posted: Tue Jul 11, 2006 1:07 pm
by Flype
But you have to remember which colors were set and which not.

>> Yes, that was the solution i was thinking of...

Posted: Sat Jul 15, 2006 2:39 pm
by gnozal
Update (both libs)

- Fixed a small listicon subclassing problem : http://www.purebasic.fr/german/viewtopi ... 2&start=10

Posted: Sun Jul 16, 2006 6:41 pm
by ABBKlaus
Hi Gnozal,

i found a bug where the Font information on a listicon is lost when i use a callback :
Image
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

Posted: Mon Jul 17, 2006 8:37 am
by gnozal
@ABBKlaus :
It's not a bug, it's how it is planned to work : maybe it's a bad design :wink:

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) ?

Posted: Mon Jul 17, 2006 12:12 pm
by ABBKlaus
Thanks for the reply Gnozal.
I only wanted to change the backcolor !
If this is the standard behavior it should be in the manual :wink:
i now use your workaround :

Code: Select all

  If IsGadget(GadgetNumber)
    *FontID\l=GetGadgetFont(GadgetNumber)
  EndIf
Klaus

Posted: Sun Aug 06, 2006 8:23 am
by magicjo
@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.

Posted: Sun Aug 06, 2006 10:46 am
by gnozal
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.
Ok, for the next version.

Posted: Mon Aug 07, 2006 7:56 am
by gnozal
Update 12.21 (both libs)

- bug fix : editable ComboBoxGadget was not colorized

Posted: Mon Aug 07, 2006 9:13 am
by magicjo
Thanks Gnozal for the update(obviously functions) :wink: