Page 20 of 35
PureColor and disabled buttons
Posted: Sat Jun 30, 2007 7:02 am
by drahneir
Hello,
in my application I have two buttons which are normally disabled. In this state the button text can be seen. But this is true only when the system colors are used. When I set the text color to another value, the color of the button surface changes to dark gray and the text can't be seen anymore.
In this state the gadget remains even when I set it back to system colors.
Re: PureColor and disabled buttons
Posted: Sat Jun 30, 2007 10:46 am
by gnozal
drahneir wrote:When I set the text color to another value, the color of the button surface changes to dark gray and the text can't be seen anymore.
Yes, disabled colored buttons don't look very nice. It's because colored buttons are in reality imagebuttons, and PureCOLOR would have to draw another image if the button is disabled...
Two workarounds :
- hide the buttons instead of disabling them
- clear the colors for disabled buttons : they will look like normal disabled buttons
Posted: Sat Jun 30, 2007 11:55 am
by drahneir
I have edited my mail, perhaps you haven't seen the last sentence.
When the button is set back to system colors, the disabled button keeps its ugly appearance.
Posted: Sat Jun 30, 2007 12:38 pm
by drahneir
Forget my last mail, with ClearGadgetColor it works.
Thanks for your help.
Posted: Sat Jun 30, 2007 12:42 pm
by gnozal
drahneir wrote:I have edited my mail, perhaps you haven't seen the last sentence.
When the button is set back to system colors, the disabled button keeps its ugly appearance.
When I say clear colors, I mean use PureCOLOR_ClearGadgetColor() and not setting system colors.
Posted: Sat Nov 24, 2007 4:17 am
by byo
Hi, Gnozal.
I think I may have found a bug (maybe not).
Code: Select all
If OpenWindow(0, #PB_Ignore, #PB_Ignore, 320, 200, "test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
TextGadget(0, 50, 50, 200, 20, "this is a normal text gadget")
TextGadget(1, 50, 100, 200, 20, "this is a text gadget with PureCOLOR")
ButtonGadget(2, 50, 150, 100, 20, "Click here")
EndIf
EndIf
PureCOLOR_SetGadgetColor(1, RGB(0,0,100), #PureCOLOR_DontSetBackColor)
Repeat
wEvent = WaitWindowEvent(10)
Select wEvent
Case #PB_Event_CloseWindow
Fim = #True
Case #PB_Event_Gadget
Select EventGadget()
Case 2
SetGadgetText(0, "this text was changed correctly!")
SetGadgetText(1, "this text was not changed correctly!")
EndSelect
EndSelect
Until Fim
In the above code, the second text gadget is not redrawn correctly (at least on my machine). Is this a normal behaviour?
Thanks for such wonderful contributions.
Posted: Sat Nov 24, 2007 8:57 am
by gnozal
byo wrote:Hi, Gnozal.
I think I may have found a bug (maybe not).
In the above code, the second text gadget is not redrawn correctly (at least on my machine). Is this a normal behaviour?
It's an expected behaviour as you have defined #PureCOLOR_DontSetBackColor as backcolor : this makes the gadget transparent, so it doesn't erase the previous text.
Here is a workaround :
Code: Select all
...
Select EventGadget()
Case 2
SetGadgetText(0, "this text was changed correctly!")
SetGadgetText(1, "this text was not changed correctly!")
RedrawWindow_(WindowID(0), 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN )
EndSelect
...
If you don't need a transparent background but only the background system color, use #PureCOLOR_SystemColor.
Posted: Sat Nov 24, 2007 11:44 am
by gnozal
Update (all PB versions)
Changes :
- menu functions rewritten : the old functions are gone, replaced by new ones. New feature : icon support.
See PureCOLOR_Test_13.pb for a code example.
Posted: Sat Nov 24, 2007 7:29 pm
by byo
Thanks a lot, gnozal. I see now.
That's a nifty workaround.
And menu with icons... Great!

Posted: Sat Nov 24, 2007 9:13 pm
by byo
Gnozal,
with that workaround, I'm seeing some flickering when all the window is being updated. Is there a way to update only the region of the textgadget reducing the flcikering?
I'm using:
to capture the textgadget's rect. How can I update only this rect using the RedrawWindow procedure?
Thanks a lot for the effort you put into your userlibs/code.
Posted: Sat Nov 24, 2007 9:23 pm
by srod
InvalidateRect_()

Posted: Sat Nov 24, 2007 9:58 pm
by byo
It's not working here:
Code: Select all
SetGadgetText(#txDicas, dica)
InvalidateRect_(WindowID(#wMain), rect, #True)
Unless there's something else to be done or I'm doing something wrong.
Thanks for the fast reply.
Posted: Sat Nov 24, 2007 10:04 pm
by srod
Well, I'm not really sure what you're doing but, if I was just wishing to re-paint a text gadget I would probably (though not always) use :
Code: Select all
InvalidateRect_(GadgetID(#txtGadget), 0, #TRUE)
You may need to add :
Code: Select all
UpdateWindow_(GadgetID(#txtGadget))
It all depends on what you're trying to do? If it is to stop flicker when updating the main window then you can try setting the #WS_CLIPCHILDREN style bit of the main window etc. There are all kinds of tricks to employ when attempting to reduce flicker and it all depends on individual circumstances whether any single 'trick' will make any difference etc.
Posted: Sun Nov 25, 2007 5:37 am
by Rook Zimbabwe
Gnozal... I would like to buy you a beer!!!

Re: PureCOLOR library : coloring gadgets (and much more)
Posted: Sun Nov 25, 2007 7:02 am
by PB
> PB4.1x :
http://freenet-homepage.de/gnozal/PureCOLOR__.zip
Link doesn't work. And neither does the 4.1x link on your home page at
http://freenet-homepage.de/gnozal/ .
