SetGadgetColor does nothing? [4.20]

Mac OSX specific forum
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

SetGadgetColor does nothing? [4.20]

Post 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?
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post by WilliamL »

Please... Fred? How about just one at a time? Textgadget or StringGadget?
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
freak
PureBasic Team
PureBasic Team
Posts: 5950
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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.
quidquid Latine dictum sit altum videtur
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post 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).
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post 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.
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post 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.
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post 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?
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
WilliamL
Addict
Addict
Posts: 1255
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Post 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!
MacBook Pro-M1 (2021), Tahoe 26.1, PB 6.30b2
Post Reply