PureCOLOR library : coloring gadgets (and much more)

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

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

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

Post by gnozal »

rnospam wrote:PB 4.41 and PureColor Version 15.03 work great.
That's interesting.
I removed some theme inactivation code as it runned ok in WinXP + Themes.
Could you check the code below ?

Code: Select all

Procedure DisableXPTheme(GadgetNumber.l) 
  Protected UxTheme.l, SetWindowTheme.l
  UxTheme = OpenLibrary(#PB_Any, "UxTheme.dll")
  If UxTheme
    SetWindowTheme = GetFunction(UxTheme, "SetWindowTheme")
    If SetWindowTheme
      CallFunctionFast(SetWindowTheme, GadgetID(GadgetNumber), @null.w, @null.w)
    EndIf
    CloseLibrary(UxTheme)
  EndIf
EndProcedure 
OpenWindow(0, 100, 300, 400, 200, "PureCOLOR test", #PB_Window_SystemMenu) 
CheckBoxGadget(1, 10, 10, 90, 20, "CheckBoxGadget 1")
OptionGadget(3, 10, 160, 300, 30, "OptionGadget 3")
If OSVersion() > #PB_OS_Windows_XP
  DisableXPTheme(1)
  DisableXPTheme(3)
EndIf
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), #White)
PureCOLOR_SetGadgetColor(3, RGB(255,0,0), #White)
;
Repeat 
Until WaitWindowEvent() = #PB_Event_CloseWindow
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
rnospam
New User
New User
Posts: 7
Joined: Fri Nov 13, 2009 10:33 pm

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

Post by rnospam »

That works,

Thanks!

Rodger NoSpam
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

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

Post by gnozal »

rnospam wrote:That works,
Thanks!
Rodger NoSpam
Ok, I will add this workaround in the next version.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
rnospam
New User
New User
Posts: 7
Joined: Fri Nov 13, 2009 10:33 pm

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

Post by rnospam »

Just tested that Latest Version..

It works as expected, thanks for your support!.

Rodger NoSpam
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

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

Post by GeBonet »

Hello
I just upload all the fresh version PureBasic 4.5 ... No apparent problem!

As with each version, I load and test a series of examples in various bookstores!
Petzold, Srod, Gdiplus, and necessarily WxWiget.Lib Gnozal Lib ...
And the "PureColor-450-Installer.exe" so I assume for PB 4.50 ...
The example below gives me the following message :
[ERREUR] Invalid memory access. (read error at address 4)
Note: Tested in 4.41, 4.40 no problem!

Code: Select all

; --------------------------------------------------------
;               PureCOLOR library test file 15
; --------------------------------------------------------
;
DataSection
	ButtonIcon:
	IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico"
EndDataSection
Button_Icon = CatchImage(#PB_Any, ?ButtonIcon)
Button_Icon_2 = Button_Icon
If OpenWindow(0, 421, 13, 270, 362, "Icon Button Test", #PB_Window_SystemMenu|#PB_Window_TitleBar)
	ButtonGadget(0, 35, 45, 200, 35, "Centered text")
	PureCOLOR_SetIconButton(0, #Green, #PureCOLOR_SystemColor, Button_Icon) ; <<< ICI === HERE 
	ButtonGadget(1, 35, 85, 200, 35, "Centered text")
	PureCOLOR_SetIconToggleButton(1, #Green, #Black, #Red, #White, Button_Icon, Button_Icon_2); <<< ICI === HERE 
	ButtonGadget(2, 35, 135, 200, 35, "Left text", #PB_Button_Left)
	PureCOLOR_SetIconButton(2, #Blue, #PureCOLOR_SystemColor, Button_Icon)
	ButtonGadget(3, 35, 185, 200, 35, "Right text", #PB_Button_Right)
	PureCOLOR_SetIconButton(3, #Blue, #PureCOLOR_SystemColor, Button_Icon)
	ButtonGadget(4, 35, 235, 200, 35, "Icon button with" + Chr(10) + "multiline text", #PB_Button_MultiLine)
	PureCOLOR_SetIconButton(4, #Blue, #PureCOLOR_SystemColor, Button_Icon)
	ButtonGadget(5, 35, 285, 200, 35, "Button with" + Chr(10) + "multiline text", #PB_Button_MultiLine)
	PureCOLOR_SetButtonColor(5, #Blue, #PureCOLOR_SystemColor)
	Repeat
		Event = WaitWindowEvent()
		Select Event
			Case #PB_Event_CloseWindow
				EventWindow = EventWindow()
				If EventWindow = 0
					CloseWindow(0)
					Break
				EndIf
		EndSelect
	ForEver
EndIf
; --------------------------------------------------------------------
Note : The other example involving an extension in PureColor produce the same effect!
For example: PureCOLOR_SetGadgetColor (1, RGB (255,0,0), -1) :) OK
PureCOLOR_SetGadgetColorEx (2, RGB (0,0,0), RGB (255, 255, 255), RGB (255, 255, 223), #PureCOLOR_LV_AlternateColors) NOT OK :(
Maybe it's not compatible??? :? But why this name: PureColor-450 :wink:
A + + :D :D
I also especially placed this message on the French forum !
Sorry for my english :wink: ! (Windows Xp, Vista and Windows 7, Windows 10)
nigel
User
User
Posts: 62
Joined: Tue Feb 23, 2010 8:39 pm
Location: Canada

Using Colour in the Graphical User Environment

Post by nigel »

As someone who is new to Purebasic, there appear to be significant limitations in the
application of colour to GUI objects in the Purebasic environment, particularly
for buttons and panel gadgets. In this regard, I find these limitations difficult to
understand and have a few questions....

Am I correct in assuming that everyone uses the Purecolor library because support
for colour in Purebasic itself has significant limitations ?

I am a little confused because the Purecolor author recommends against using
this library wherever possible. It seems to me that it would be difficult to use
Purebasic for any significant development effort without using the Purecolor library.
Am I right in thinking that almost all experienced Purebasic programmers use this
library ?

As a side comment, I find the Purebasic help documentation to be very difficult
to follow for new users. This is mainly because the documentation consistently fails
to adequately define or explain parameters clearly. A good example of this can
be seen when looking at examples depicting the application of colour in Menu and
Gadget items.

Any comments would be appreciated.
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Using Colour in the Graphical User Environment

Post by IdeasVacuum »

Hello Nigel

The Pure Basic Forms Designer is relatively new, so there are a few things that could be better and surely will be in the future. However, it's a great little tool for graphically defining the layout of gadgets on a form, the 'scheme' for want of a better description. It is then a trivial matter to enhance the appearance by editing the code.

On the Windows platform, much of the colourisation of gadgets is dependent on whether or not your forms are to inherit the XP style, which does bring about limitations. However, for buttons, you can use a bitmap to deliver the colour if required ('ButtonImageGadget'). Gadgets such as text boxes ('StringGadget') can be customized with 'SetGadgetColor' and 'SetGadgetFont' etc - it's all in the help pages and could not be easier to code.

http://www.purebasic.com/documentation/ ... color.html
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
nigel
User
User
Posts: 62
Joined: Tue Feb 23, 2010 8:39 pm
Location: Canada

Re: Using Colour in the Graphical User Environment

Post by nigel »

Hello IdeasVacuum

Thanks for your comments. It is valuable for new users (like me) to receive feedback from others like yourself
even if it is only to confirm that I am not missing something fundamental.

I had initially tried the visual designer that is included with Purebasic but had since found Pureform
from Gnozal, which (so far) I like better. Pureform appears to have good colour support included, although
this seems to need the Purecolor library which is not recommended by its author (Gnozal).
I assume the recommendation to avoid using Purecolor is because it is not natively supported by
Purebasic and therefore might be a future liability of some sort.

I did not realise that the standard Purebasic visual designer was relatively new. Perhaps this
explains why it has no significant colour support even though this is a surprising deficiency.
It is unfortunate that the native Purebasic colour support is not already built into the
visual design tools.

It had occurred to me that I could use images to colour certain gadgets and your suggestion
confirms that perhaps this would be a better approach instead of using Purecolor. Also the
existence of both Microsoft Vista and Win 7 already made me unlikely to think about using XP
style inheritance.

Thanks again for your valuable guidance. It is much appreciated.
nigel
User
User
Posts: 62
Joined: Tue Feb 23, 2010 8:39 pm
Location: Canada

gnozal - Question about Purecolor

Post by nigel »

I am new to Purebasic and have been trying out your PureForm product which
I prefer in comparison to the Visual design tool included as standard with Purebasic.

I am particularly interested in knowing the reason you generally recommend
against using Purecolor, as this seems to be the only satisfactory way to
use colour in Panel and Button gadgets. So far I have been very surprised
at the poor level of colour support included within Purebasic and I see
Purecolor as a good solution to this deficiency even if it does involve using
an external library.

I have noted with interest that using Purecolor in the Pureform environment
to colour panel and button gadgets causes interface elements of Pureform
to inherit the same colours. Is this due to rigidities of the "class" concept ?

Any comments would be appreciated.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

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

Post by gnozal »

GeBonet wrote:I just upload all the fresh version PureBasic 4.5 ... No apparent problem!
As with each version, I load and test a series of examples in various bookstores!
Petzold, Srod, Gdiplus, and necessarily WxWiget.Lib Gnozal Lib ...
And the "PureColor-450-Installer.exe" so I assume for PB 4.50 ...
The example below gives me the following message :
[ERREUR] Invalid memory access. (read error at address 4)
No error here, even with purifier enabled.
However, I will recompile all librairies with PB4.50 final.
GeBonet wrote:Note : The other example involving an extension in PureColor produce the same effect!
For example: PureCOLOR_SetGadgetColor (1, RGB (255,0,0), -1) :) OK
PureCOLOR_SetGadgetColorEx (2, RGB (0,0,0), RGB (255, 255, 255), RGB (255, 255, 223), #PureCOLOR_LV_AlternateColors) NOT OK :(
No problems here with #PureCOLOR_LV_AlternateColors using PureCOLOR_TEST.pb.
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:

Re: gnozal - Question about Purecolor

Post by gnozal »

nigel wrote:I have noted with interest that using Purecolor in the Pureform environment
to colour panel and button gadgets causes interface elements of Pureform
to inherit the same colours. Is this due to rigidities of the "class" concept ?
Yes, it is.
Some PureCOLOR functions use the SetClassLong() API (panels and containers iirc).
I may change this in the future.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
nigel
User
User
Posts: 62
Joined: Tue Feb 23, 2010 8:39 pm
Location: Canada

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

Post by nigel »

gnozal

Thanks for your answer on the interface colouring issue.

I am still interested in understanding your reasons for recommending
against the use of Purecolor. Is it just because it involves an external
library and because you think the Purebasic author may eventually
improve colour support natively within the language itself ?
User avatar
GeBonet
Enthusiast
Enthusiast
Posts: 135
Joined: Fri Apr 04, 2008 6:20 pm
Location: Belgium

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

Post by GeBonet »

Tanks for the reply... :D
No error here, even with purifier enabled.
However, I will recompile all librairies with PB4.50 final.
I just reload bookstores and apparently it works ... :D
Sorry for my english :wink: ! (Windows Xp, Vista and Windows 7, Windows 10)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

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

Post by gnozal »

nigel wrote:I am still interested in understanding your reasons for recommending against the use of Purecolor. Is it just because it involves an external library and because you think the Purebasic author may eventually improve colour support natively within the language itself ?
I am not recommending not to use PureCOLOR (I use it myself), but to use PB genuine functions whenever it's possible.
Several reasons :
- PureCOLOR does not support themes (it could have better support for themes, but it would be a lot of work and I am not using themes anyway, so...)
- some PB gadgets are not 100% Windows API compatible, so using an external library for coloring may have some unexpected results : the listicon grid lines issue, the combobox coloring not working when #PB_ComboBox_Image is used, ....
I don't think the PB authors will improve color support a lot because most users use themes, and they have 3 OS to support. But I may be wrong.

PureFORM uses PureCOLOR internally because it's an old app written with PB3.9x which had absolutely no color support at the time, nor icon menus.
However, in the generated code, you can choose between PureCOLOR and the genuine SetGadgetColor() function, and this for every class. It may not be supported by PB though.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
SoS
User
User
Posts: 13
Joined: Sat Feb 18, 2006 4:46 am

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

Post by SoS »

Hi gnozal
PureColor is not working in threadsafe mode.(winxp 32)
I get "unresolved external.... _PB_Stringbase".
Post Reply