
Is a simple way to choose color or font. Not is nothing new but simplify work with this two requesters.

I dont know if other similar code is in this forum. thats all friends.

Code: Select all
Procedure ColorBrillo(color)
Protected brillo=Red(color)+Green(color)+Blue(color)
ProcedureReturn brillo
EndProcedure
Procedure ColorGadgetRequester(Gadget)
SetActiveGadget(-1)
Protected color = ColorRequester(GetGadgetColor(Gadget,#PB_Gadget_BackColor))
Delay(100) : If color > -1 : SetGadgetColor(Gadget,#PB_Gadget_BackColor,color) : EndIf
ProcedureReturn color
EndProcedure
Procedure FontGadgetRequester(Gadget, font=-1,sizelock=-1)
SetActiveGadget(-1)
Protected fontname.s = StringField(GetGadgetText(gadget),1,",")
Protected fontsize = Val(StringField(GetGadgetText(gadget),2,","))
Protected fontcolor = GetGadgetColor(Gadget,#PB_Gadget_FrontColor)
Protected fontstyle = Val(StringField(GetGadgetText(gadget),3,","))
Protected fontchoose = FontRequester(fontname,fontsize,#PB_FontRequester_Effects ,fontcolor,fontstyle)
Delay(100)
If fontchoose
fontname.s = SelectedFontName()
fontsize = SelectedFontSize()
fontcolor = SelectedFontColor()
fontstyle = SelectedFontStyle()
SetGadgetText(Gadget,fontname+","+Str(fontsize)+","+Str(fontstyle))
SetGadgetColor(Gadget,#PB_Gadget_FrontColor,fontcolor)
If ColorBrillo(fontcolor) > 350
SetGadgetColor(Gadget,#PB_Gadget_BackColor,0)
Else
SetGadgetColor(Gadget,#PB_Gadget_BackColor,$FFFFFF)
EndIf
If font > -1
If IsFont(font):FreeFont(font):EndIf
If sizelock > -1 : fontsize=sizelock : EndIf
LoadFont(font,fontname,fontsize,fontstyle | #PB_Font_HighQuality)
SetGadgetFont(Gadget,FontID(font))
EndIf
EndIf
EndProcedure
;{ Ejemplo
CompilerIf Not #PB_Compiler_IsIncludeFile
Window_0 = OpenWindow(#PB_Any, 450, 200, 400, 125, "ColorGadgetRequester", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
String_1 = StringGadget(#PB_Any, 145, 20, 160, 20, "", #PB_String_ReadOnly)
SetGadgetColor(String_1,#PB_Gadget_BackColor,$FFFFFF)
GadgetToolTip(String_1,"Clik me!")
Text_1 = TextGadget(#PB_Any, 75, 20, 73, 20, "Choose color", #PB_Text_Border|#PB_Text_Center|#SS_CENTERIMAGE)
String_2 = StringGadget(#PB_Any, 145, 50, 160, 20, "", #PB_String_ReadOnly)
SetGadgetColor(String_2,#PB_Gadget_BackColor,$FFFFFF)
GadgetToolTip(String_2,"Clik me!")
Text_2 = TextGadget(#PB_Any, 75, 50, 73, 20, "Choose color", #PB_Text_Border|#PB_Text_Center|#SS_CENTERIMAGE)
String_3 = StringGadget(#PB_Any, 145, 80, 160, 20, "Arial,10,0", #PB_String_ReadOnly)
SetGadgetColor(String_3,#PB_Gadget_BackColor,$FFFFFF)
GadgetToolTip(String_2,"Clik me!")
Text_3 = TextGadget(#PB_Any, 75, 80, 73, 20, "Choose Font", #PB_Text_Border|#PB_Text_Center|#SS_CENTERIMAGE)
Repeat
Event = WaitWindowEvent(1)
Select Event
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = String_1 ; color
If EventType = #PB_EventType_Focus
color=ColorGadgetRequester(EventGadget)
EndIf
ElseIf EventGadget = String_2 ; color
If EventType = #PB_EventType_Focus
color=ColorGadgetRequester(EventGadget)
EndIf
ElseIf EventGadget = String_3 ; font
If EventType = #PB_EventType_Focus
FontGadgetRequester(EventGadget,1,10)
EndIf
EndIf
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = Window_0
CloseWindow(Window_0)
Window_0 = 0
Break
EndIf
EndSelect
ForEver
CompilerEndIf
;}