It is currently Sat May 25, 2013 12:08 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Testing window & gadgets colors
PostPosted: Thu May 03, 2012 9:27 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 03, 2007 2:38 pm
Posts: 150
Location: To the deal with a pepper
Hi,
if you need to know how shows your program colors, try this:
Code:
Global my_COLORS.s = "250,255,220|255,225,255|225,250,225|64,255,64|200,200,200|0,32,64|225,250,225|255,200,80|210,190,140"
Global d2h.s = "0123456789ABCDEF"

macro Dec2Hex(n)
  mid(d2h,(n/16)+1,1)+mid(d2h,(n%16)+1,1)
endmacro
macro divide_cols(col)
  val(StringField(col,1,",")), val(StringField(col,2,",")), val(StringField(col,3,","))
endmacro

Procedure SetTracks(rd,gr,bl)
  co = RGB(rd,gr,bl)
  hcolor.s = "$"+Dec2Hex(bl)+Dec2Hex(gr)+Dec2Hex(rd)
  SetGadgetState(1,rd)
  SetGadgetState(2,gr)
  SetGadgetState(3,bl)
  SetGadgetText (11,Rset(str(rd),3,"0"))
  SetGadgetText (12,Rset(str(gr),3,"0"))
  SetGadgetText (13,Rset(str(bl),3,"0"))
  SetGadgetText (14,hcolor)
  SetGadgetText (15,str(co))
  SetGadgetColor(21,#PB_Gadget_FrontColor,0)
  SetGadgetColor(21,#PB_Gadget_BackColor,co)
  SetGadgetColor(22,#PB_Gadget_FrontColor,$FFFFFF)
  SetGadgetColor(22,#PB_Gadget_BackColor,co)
  SetGadgetColor(23,#PB_Gadget_FrontColor,co)
  SetGadgetColor(23,#PB_Gadget_BackColor,0)
  SetGadgetColor(24,#PB_Gadget_FrontColor,co)
  SetGadgetColor(24,#PB_Gadget_BackColor,$FFFFFF)
  SetGadgetColor(25,#PB_Gadget_FrontColor,co)
EndProcedure

Openwindow(0, 0, 0, 320,160, "Testing Colors",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
 TrackbarGadget( 1, 55, 10,256, 25, 0, 255)
 TrackbarGadget( 2, 55, 45,256, 25, 0, 255)
 TrackbarGadget( 3, 55, 80,256, 25, 0, 255)
 TextGadget    ( 4,  2, 13, 30, 15, "Red")
 TextGadget    ( 5,  2, 48, 30, 15, "Green")
 TextGadget    ( 6,  2, 83, 30, 15, "Blue")
 TextGadget    (11, 32, 13, 20, 15, "000")
 TextGadget    (12, 32, 48, 20, 15, "000")
 TextGadget    (13, 32, 83, 20, 15, "000")
 SetGadgetColor(11, #PB_Gadget_FrontColor, RGB(200,0,0))
 SetGadgetColor(12, #PB_Gadget_FrontColor, RGB(0,128,0))
 SetGadgetColor(13, #PB_Gadget_FrontColor, RGB(0,0,200))
 TextGadget    (14,  2,118, 50, 20, "$000000")
 TextGadget    (15, 55,118, 50, 20, "0",#PB_Text_Right)
 ButtonGadget  (19,  5,142, 55, 15, "ClipBoard")
 for n=1 to 5
   TextGadget  (20+n,110+((n-1)*40),115, 40, 20, "TEST",#PB_Text_Border|#PB_Text_Center)
 next
 for n=1 to 9
   StringGadget(30+n,110+((n-1)*20),142, 15, 15, " "+str(n),#PB_String_ReadOnly)
   color.s = StringField(my_COLORS,n,"|")
   SetGadgetColor(30+n, #PB_Gadget_BackColor, RGB(divide_cols(color)))
 next
 SetGadgetColor(36, #PB_Gadget_FrontColor, #White)
 hcolor.s = ""

Repeat
  select Waitwindowevent()
    case #PB_Event_CloseWindow: break
    case #PB_Event_Gadget
         nGad = EventGadget()
         if nGad = 19
            if len(hcolor): SetClipboardText(hcolor): endif
         elseif nGad > 30 AND nGad < 40
            if EventType() = #PB_EventType_Focus
              ncol  = nGad - 30
              color = StringField(my_COLORS,ncol,"|")
              rd    = val(StringField(color,1,","))
              gr    = val(StringField(color,2,","))
              bl    = val(StringField(color,3,","))
              SetTracks(rd,gr,bl)
            endif
         else
            rd = GetGadgetState(1)
            gr = GetGadgetState(2)
            bl = GetGadgetState(3)
            SetTracks(rd,gr,bl)
         endif
  endselect
Forever

END


Top
 Profile  
 
 Post subject: Re: Testing window & gadgets colors
PostPosted: Thu May 03, 2012 10:39 am 
Offline
Enthusiast
Enthusiast

Joined: Mon May 14, 2007 2:13 am
Posts: 734
Location: Darling River
Interesting,
Added: Global hcolor.s = "$000000"
Comment Out: ;hcolor.s = ""
To get paste to clipboard to work properly.

_________________
PureBasic Rocks! Even More! And More!
PureBasic 5, Now We're Really Rockin!


Top
 Profile  
 
 Post subject: Re: Testing window & gadgets colors
PostPosted: Thu May 03, 2012 4:54 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Oct 31, 2006 4:34 am
Posts: 427
Nice code graves
I made something similar about 6 years ago, in which you could with sliders like
you use, select a color. It also allowed you to select an objects color from your
desktop and paste it into the program. You could also paste the resultant color
code into your PB IDE editor if you wanted to. It was just a solid color though.
I like what you did by showing the effects of color in the text boxes below.
That gives you a nice view of the final results you want to achieve, because
sometimes a color you may think looks okay, really isn't when combined with the
text.
Nice job.
Thanks for sharing.


Top
 Profile  
 
 Post subject: Re: Testing window & gadgets colors
PostPosted: Thu May 03, 2012 5:26 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 03, 2007 2:38 pm
Posts: 150
Location: To the deal with a pepper
Hi again,
Quote:
It also allowed you to select an objects color from your
desktop and paste it into the program
Select a color from any desktop object is a good idea. I will work to include it.

Regards


Top
 Profile  
 
 Post subject: Re: Testing window & gadgets colors
PostPosted: Fri May 04, 2012 2:08 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 218
Location: Brisbane, Qld, Australia
A useful tool - thanks.

_________________
Mike


Top
 Profile  
 
 Post subject: Re: Testing window & gadgets colors
PostPosted: Fri May 04, 2012 1:07 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 2513
Location: Lyon - France
Thanks for sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye