Page 1 of 1

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

Posted: Thu Apr 19, 2007 8:22 pm
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...

Posted: Thu Apr 19, 2007 9:06 pm
by bembulak
Nice one! I like it.

Posted: Sun Apr 22, 2007 9:58 am
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