PureCOLOR library : coloring gadgets (and much more)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

PureColor and disabled buttons

Post 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.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureColor and disabled buttons

Post 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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Post 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.
drahneir
Enthusiast
Enthusiast
Posts: 105
Joined: Tue Jul 18, 2006 4:18 pm
Location: JO42RM

Post by drahneir »

Forget my last mail, with ClearGadgetColor it works.
Thanks for your help.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post 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.
Proud registered Purebasic user.
Because programming should be fun.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Thanks a lot, gnozal. I see now.
That's a nifty workaround.

And menu with icons... Great! :D
Proud registered Purebasic user.
Because programming should be fun.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post 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:

Code: Select all

GetWindowRect_(GadgetID(0), rect)
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.
Proud registered Purebasic user.
Because programming should be fun.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

InvalidateRect_() :?:
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post 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.
Proud registered Purebasic user.
Because programming should be fun.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Gnozal... I would like to buy you a beer!!! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PureCOLOR library : coloring gadgets (and much more)

Post 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/ . :(
Post Reply