ColorSelector - Gadget : for Linux and Windows (PB 4.x)

Developed or developing a new product in PureBasic? Tell the world about it.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

ColorSelector - Gadget : for Linux and Windows (PB 4.x)

Post by walker »

Here's a little Gadget I'd needed for my app... I decided to release it so maybe someone can improve it if desired... (for me this version works well)
Should compile on Windows and Linux without change....

here's a screenshot:
Image


a small demo-App (compiled on Linux) where you simply can change the Background color (maybe not visible on all machines due to the different theming-engines):
http://home.arcor.de/x-linux/pure/col_picker

and the source:
http://home.arcor.de/x-linux/pure/col_picker.pb

the demo-app (source):

Code: Select all

;- demo
 XIncludeFile "col_picker.pb"
Procedure select_color()
    back_color=$80667F
    a=col_picker(20,back_color)      
    If a >-2
        SetWindowColor(0,a)
    EndIf
EndProcedure
OpenWindow(0,0,0,200,200,"Color-Select",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)

If CreateGadgetList(WindowID(0))
    *button1=ButtonGadget(#PB_Any,50,50,100,25,"click me")
    registerGadgetEvent(*button1,@select_color())
    
EndIf
Repeat
  Event  = WaitWindowEvent()
  Gadget = EventGadget()
  Type   = EventType()
  Window = EventWindow()
  Select Event
    Case #PB_Event_Gadget
      CallEventFunction(Window, Event, Gadget, Type)   
    Case #PB_Event_CloseWindow 
        quit=1
  EndSelect
Until quit=1
End
I guess, it's self-explanatory.... but if you have questions, feel free to ask
As always, comments, suggestions etc. are welcome

It's planned, to release a similar gadget as a toolbarbutton (like the colorselector in the toolbars of gnumeric, office-calc, excel etc.) but this will take a while...
Last edited by walker on Sun Apr 22, 2007 9:59 am, edited 1 time in total.
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Nice one! I like it.
cheers,

bembulak
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Update:

- added : a few comments
- fixed : a minor bug (if no color was choosen, the color was always black)
- added : a button to remove te color
- added : a parameter to set the background color of the color select window

download see first post; example in first post is updated
Post Reply