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:

Post by gnozal »

Update 12.22 (both libs)

- changed PanelGadget coloring method
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
magicjo
User
User
Posts: 61
Joined: Sun May 07, 2006 10:43 am
Location: Italy

Post by magicjo »

@gnozal, settings the colors for Frame3DGadget and OptionGadget don't work very well when xp theme is enabled: is possibile to do anything ?

Thanks in advance.
PB Registered User, Egrid Registered User
Win7 x64 Ultimate, 4,00 Gb Mem, Ati Radeon HD4600 Series, Realtek High Definition Audio Integrated
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

magicjo wrote:@gnozal, settings the colors for Frame3DGadget and OptionGadget don't work very well when xp theme is enabled: is possibile to do anything ?
I fear not.
Because :
- I don't have XP to test (yet) ...
- M$ is not compliant with it's own specifications when it comes to XP themes (some API calls don't function correctly).
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 (PB4 version only)

Changes :
- added unicode / unicode+threadsafe versions
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Yeha, I've waited for this feature!

But, how to instal and use the Lib? I wish, that I only have to enable "Compiler Threadsafe". I don't want to use the Subsystem things. Or do I have to?
PB 4.30

Code: Select all

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

Post by gnozal »

AND51 wrote:But, how to instal and use the Lib?
PureCOLOR.chm wrote:This library exists in several versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
- the unicode version, located in %Purebasic%\SubSystems\UserLibUnicode\PureLibraries\ .
- the unicode + thread-safe version, located in %Purebasic%\SubSystems\UserLibunicodeThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the
subsystem 'UserLibThreadSafe' in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the
PBCompiler arguments. In jaPBe, do nothing : it will automatically enable the 'UserLibThreadSafe'
subsystem to use the threadsafe versions of the installed userlibraries.
It's the same logic for unicode and unicode + thread-safe modes.
AND51 wrote:But, how to instal and use the Lib?. I don't want to use the Subsystem things. Or do I have to?
I you use jaPBe V3, you don't have to (it's automatic).
If you use the PBIDE, enable the subsystem you need : if you need threadsafe, add "UserLibThreadSafe" in the "Library Subsystem" stringgadget in the "Compiler Options" window.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

gnozal wrote:- added unicode / unicode+threadsafe versions
Great - thanks alot!
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Scanned all 17 pages but maybe I missed it.

I have the latest lib.

PureColor doesn't work on a multiline button?

result = ButtonGadget(#MenuBar_0_SelectAll, 5, 435, 40, 40, "Select"+Chr(10)+" All",#PB_Button_MultiLine|#BS_FLAT)

Tried several variations on that theme but can't get it to work.

Fine without PureColor.

Is it me? Is it possible?

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

Post by gnozal »

rsts wrote:PureColor doesn't work on a multiline button?
You are right, multiline buttons are not supported. I don't use multiline buttons myself, so I never thought of supporting them.
I will see what I can do when I have some time.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post by RichardL »

BACKGROUND
=========
I have an array of buttons that double up as string gadgets that report values input via RS232.

The user can click once on a button and this becomes the target for data received from external hardware and I colour it to show the selected item. Then, if the external hardware sends a value it goes to the button, the button background colour is cleared and the text shown in RED.

If the user clicks twice then an editor pops up and he can enter data manually, the background is removed and the value is shown in BLUE.

After the end of the test you can see how many results were supplied automatically or manually.

This all works fine, thanks to your library, and the users like the ability to gain a quick appreciation of how a test sequence is progressing.

The only problem I have left is when the user clicks twice on a RED result, accidently goes into the editor, exits without editing (which I can detect) and I need to re-instate the original RED.

All my problems would go away if I could read back the colours from a button. I cannot think of a better solution... overall its quite a complex program and runs on a tablet PC and there are actually many more interactions than outlined above.

REQUEST
======
Please could PureCOLOR_SetButtonColor() be matched with PureCOLOR_GetButtonColor() ?

If not, could you kindly suggest a less elegant way of getting the colours set into a ButtonGadget().

Thanks in advance...
Last edited by RichardL on Fri Oct 27, 2006 3:00 pm, edited 1 time in total.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

RichardL wrote:REQUEST
======
Please could PureCOLOR_SetButtonColor() be matched with PureCOLOR_GetButtonColor() ?
Ok, on the to-do list.
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 (Both versions)

Changes :
- new function PureCOLOR_GetGadgetColor() ;
- multiline buttons should now be colored correctly (note that PureCOLOR assumes that buttons with #BS_Multiline style are centered (no #BS_Left or #BS_Right style).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

very quick.

Thanks gnozal :)

cheers
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hi! I've got a problem with the menu coloring. When activation PureColor for the menu, the MenuItem resets. Maybe i'm missing something.
Here's a quick example that should debug 1,2,3,4,5,6,7,8, etc. But it only debugs from 1 to 3...

Code: Select all

If OpenWindow(0, 10, 10, 300, 200, "Ownerdraw Menu Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
  If CreateMenu(0, WindowID(0)) 
    MenuTitle("Menu 1") 
    MenuItem(1, "Menu item 1") 
    MenuItem(2, "Menu item 2") 
    MenuItem(3, "Menu item 3") 
    MenuItem(4, "Exit") 
    MenuTitle("Menu 2") 
    MenuItem(5, "Menu item 1") 
    MenuItem(6, "Menu item 2 (longer)")
    MenuItem(7, "Menu item 3")
    MenuTitle("Extra menu") 
    MenuItem(8, "Extra long menu item") 
    OpenSubMenu("The level 1 submenu")
    MenuItem(9, "The pure power !") 
    OpenSubMenu("The level 2 submenu")
    MenuItem(10, "What ?") 
    MenuItem(11, "Hello ...") 
    CloseSubMenu()
    CloseSubMenu()
  EndIf
  ;
  ; MENU COLORS
  ; -------------
  ; Owner drawn :
  ; -------------
  PureCOLOR_SetMenuColors(0, #Red, RGB(200, 255, 200), #Red, RGB(100, 255, 100))
  PureCOLOR_SetWindowColor(0, RGB(200, 255, 200))
  ; -------------
  ; or not (but then only backcolor) : 
  ; -------------
  ;PureCOLOR_SetPopupMenuBackColor(0, RGB(200, 255, 200))
  ; -------------
  Repeat 
    event = WaitWindowEvent() 
    If event = #PB_Event_Menu
     Debug EventMenu()
    EndIf
  Until event = #PB_Event_CloseWindow 
EndIf
End

None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Inf0Byt3 wrote:Hi! I've got a problem with the menu coloring. When activation PureColor for the menu, the MenuItem resets. Maybe i'm missing something.
Here's a quick example that should debug 1,2,3,4,5,6,7,8, etc. But it only debugs from 1 to 3...
As stated in the help file, PureCOLOR uses it's own menu numbering (see help topics for PureCOLOR_SetMenuItemColors() and PureCOLOR_EventMenuID()). To get the correct event menu id, you have to use PureCOLOR_EventMenuID(). Sorry for this inconvenience.

Code: Select all

If OpenWindow(0, 10, 10, 300, 200, "Ownerdraw Menu Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
  If CreateMenu(0, WindowID(0)) 
    MenuTitle("Menu 1") 
    MenuItem(1, "Menu item 1") 
    MenuItem(2, "Menu item 2") 
    MenuItem(3, "Menu item 3") 
    MenuItem(4, "Exit") 
    MenuTitle("Menu 2") 
    MenuItem(5, "Menu item 1") 
    MenuItem(6, "Menu item 2 (longer)") 
    MenuItem(7, "Menu item 3") 
    MenuTitle("Extra menu") 
    MenuItem(8, "Extra long menu item") 
    OpenSubMenu("The level 1 submenu") 
    MenuItem(9, "The pure power !") 
    OpenSubMenu("The level 2 submenu") 
    MenuItem(10, "What ?") 
    MenuItem(11, "Hello ...") 
    CloseSubMenu() 
    CloseSubMenu() 
  EndIf 
  ; 
  ; MENU COLORS 
  ; ------------- 
  ; Owner drawn : 
  ; ------------- 
  PureCOLOR_SetMenuColors(0, #Red, RGB(200, 255, 200), #Red, RGB(100, 255, 100)) 
  PureCOLOR_SetWindowColor(0, RGB(200, 255, 200)) 
  ; ------------- 
  ; or not (but then only backcolor) : 
  ; ------------- 
  ;PureCOLOR_SetPopupMenuBackColor(0, RGB(200, 255, 200)) 
  ; ------------- 
  Repeat 
    event = WaitWindowEvent() 
    If event = #PB_Event_Menu 
      Debug EventMenu() 
      Debug PureCOLOR_EventMenuID()
    EndIf 
  Until event = #PB_Event_CloseWindow 
EndIf 
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply