Page 1 of 1

SetGadgetColor does nothing? [4.20]

Posted: Tue Sep 02, 2008 5:31 pm
by WilliamL
Well, I get text color in the Editor Gadget...

Code: Select all

If OpenWindow(0, 0, 0, 200, 210, "SetGadgetColor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    StringGadget(0, 10, 10, 180, 20, "String...")
    ListViewGadget(1, 10, 32, 180, 60)
    For i = 0 To 4
      AddGadgetItem(1, -1, Str(i)+"Text")
    Next i
    TextGadget(3,10,184,180,20,"Text gadget",#PB_Text_Border)
    EditorGadget(2, 10, 92, 180, 80) ; must be last?
    For i = 0 To 4
      AddGadgetItem(2, -1, Str(i)+"Text")
    Next i
    
    SetGadgetColor(0, #PB_Gadget_BackColor, $00FFFF)
    SetGadgetColor(0, #PB_Gadget_FrontColor, $0000FF)
    SetGadgetColor(1, #PB_Gadget_FrontColor, $0000FF)
    SetGadgetColor(1, #PB_Gadget_BackColor, $00FFFF)
    SetGadgetColor(2, #PB_Gadget_FrontColor, $0000FF)
    SetGadgetColor(2, #PB_Gadget_BackColor, $00FFFF)
    SetGadgetColor(3, #PB_Gadget_FrontColor, $0000FF)
    SetGadgetColor(3, #PB_Gadget_BackColor, $00FFFF)
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Does this work in 4.30?

William

Where is everybody? Gone till 4.30?

Posted: Thu Oct 09, 2008 11:53 pm
by WilliamL
Please... Fred? How about just one at a time? Textgadget or StringGadget?

Posted: Fri Oct 10, 2008 12:28 am
by freak
The color options on OSX are very poor. If it does not work, its probably not possible. I spent quite some time implementing coloring wherever possible.

Posted: Fri Oct 10, 2008 4:11 am
by WilliamL
Well, at least I have more info than before and I have a better idea of what to expect but that is very discouraging. Maybe just changing the color of the text in the gadgets? Otherwise, it sounds like, I'm doomed to live in a grey and white world (with black text).

Posted: Fri Oct 10, 2008 12:25 pm
by aaron
The OSX GUI is fairly locked down by Apple so that apps have a consistent look and feel. If you want to step outside that, you need to start using custom GUI elements I guess.

Posted: Fri Oct 10, 2008 5:27 pm
by WilliamL
I went back to the manual, it said 'Supported OS All'. You need to change the manual and then there won't be any complaints.

Posted: Sun Oct 12, 2008 9:36 pm
by WilliamL
Actually the StringGadget will show color with #PB_Gadget_BackColor and with #PB_Gadget_FrontColor but only if the font size is not changed.

Hey, Fr34k, it works.. so all we need is to be able to change the font size and still be able to get the colors!

Code: Select all

If OpenWindow(0, 0, 0, 200, 60, "SetGadgetColor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    
    If LoadFont(0, "Monaco",10)
        SetGadgetFont(#PB_Default, FontID(0))   ; this is over-ridden by color commands
    EndIf

    StringGadget(0, 10, 10, 180, 21, "String...wrong text size") ; should be tiny
        SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0,200,200)) ; either of these force wrong size text
        SetGadgetColor(0, #PB_Gadget_FrontColor, $0000FF) ; either of these force wrong size text

  Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
Can you fix it?

Posted: Fri Nov 14, 2008 10:58 pm
by WilliamL
Color does work with the StringGadget but only if you set the gadget font after setting the color. All sizes and fonts have worked so far. I can't quite tell if the spacing is a little off. There seems to be a need for a little more extra space in the gadget at the end of the text when you use color. Every time you change the text you have to reset the font.

Code: Select all

   ; not a complete example
    a$="String text size"
    StringGadget(#gadget1, 10, 10, 180, fh*lne,"")
        SetGadgetText(#gadget1,a$) ; must be in this order!
        SetGadgetColor(#gadget1, #PB_Gadget_BackColor, RGB(0,200,200))
        SetGadgetColor(#gadget1, #PB_Gadget_FrontColor, $0000FF) 
        SetGadgetFont(#gadget1,FontID(fontused)) ; must use to re-set to wanted font
Works for me!