*Füllfarbe auswählen geht
*randfarbe auswählen geht
*form auswählen geht
An die Moderatoren:Wenn dies der falsche ort ist zur veröffentlichung bitte verschieben!
Code: Alles auswählen
----Maindatei.pb-----
IncludeFile "Common.pb"
Open_Window_0()
color=0
fuell=GetSysColor_(#Window_0)
backgr=GetSysColor_(#Window_0)
Createimages(0,fuell,backgr)
Repeat ; Start of the event loop
Event = WaitWindowEvent() ; This line waits until an event is received from Windows
WindowID = EventWindowID() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadgetID() ; Is it a gadget event?
EventType = EventType() ; The event type
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_EventGadget
If GadgetID = #Combo_0
ElseIf GadgetID = #Combo_1
Debug GetGadgetState(#Combo_1)
If GetGadgetState(#Combo_1)=0
SetGadgetState(#imagegad_0,UseImage(#img_quad1))
DisableGadget(#Text_3,1)
DisableGadget(#Spin_0,1)
DisableGadget(#text_back,1)
DisableGadget(#string_back,1)
DisableGadget(#button_back,1)
EndIf
If GetGadgetState(#Combo_1)=1
SetGadgetState(#imagegad_0,UseImage(#img_quad2))
DisableGadget(#Text_3,1)
DisableGadget(#Spin_0,1)
DisableGadget(#text_back,0)
DisableGadget(#string_back,0)
DisableGadget(#button_back,0)
EndIf
If GetGadgetState(#Combo_1)=2
SetGadgetState(#imagegad_0,UseImage(#img_round1))
DisableGadget(#Text_3,0)
DisableGadget(#Spin_0,0)
DisableGadget(#text_back,0)
DisableGadget(#string_back,0)
DisableGadget(#button_back,0)
EndIf
If GetGadgetState(#Combo_1)=3
SetGadgetState(#imagegad_0,UseImage(#img_maske_80x30))
DisableGadget(#Text_3,0)
DisableGadget(#Spin_0,0)
DisableGadget(#text_back,0)
DisableGadget(#string_back,0)
DisableGadget(#button_back,0)
EndIf
ElseIf GadgetID = #String_0
ElseIf GadgetID = #String_1
ElseIf GadgetID = #String_2
ElseIf GadgetID = #String_3
ElseIf GadgetID = #Spin_0
ElseIf GadgetID = #String_5
ElseIf GadgetID = #Button_0
fontwahl=FontRequester("Arial",10,0)
ElseIf GadgetID = #Button_1
farbwahl1.l=ColorRequester()
SetGadgetText(#String_0,GetColorCode(farbwahl1))
Createimages(farbwahl1,fuell,backgr)
If GetGadgetState(#Combo_1)=3
SetGadgetState(#imagegad_0,UseImage(#img_maske_80x30))
EndIf
If GetGadgetState(#Combo_1)=2
SetGadgetState(#imagegad_0,UseImage(#img_round1))
EndIf
If GetGadgetState(#Combo_1)=1
SetGadgetState(#imagegad_0,UseImage(#img_quad2))
EndIf
If GetGadgetState(#Combo_1)=0
SetGadgetState(#imagegad_0,UseImage(#img_quad1))
EndIf
ElseIf GadgetID = #Button_2
farbwahl2.l=ColorRequester()
Createimages(farbwahl1,farbwahl2,backgr)
If GetGadgetState(#Combo_1)=3
SetGadgetState(#imagegad_0,UseImage(#img_maske_80x30))
EndIf
If GetGadgetState(#Combo_1)=2
SetGadgetState(#imagegad_0,UseImage(#img_round1))
EndIf
If GetGadgetState(#Combo_1)=1
SetGadgetState(#imagegad_0,UseImage(#img_quad2))
EndIf
If GetGadgetState(#Combo_1)=0
SetGadgetState(#imagegad_0,UseImage(#img_quad1))
EndIf
ElseIf GadgetID = #Button_3
farbwahl3=ColorRequester()
ElseIf GadgetID = #button_back
farbwahl3=ColorRequester()
Createimages(farbwahl1,farbwahl2,farbwahl3)
EndIf
EndIf
Until Event = #PB_Event_CloseWindow ; End of the event loop
End
;
----Common.pb--------
;- Window Constants
Enumeration
#Window_0
#screen_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Text_0
#Text_1
#Text_2
#Text_3
#Text_4
#Text_5
#Text_6
#Text_7
#text_back
#Combo_0
#Combo_1
#String_0
#String_1
#String_2
#String_3
#string_back
#Spin_0
#String_5
#Button_0
#Button_1
#Button_2
#Button_3
#button_back
#Frame3D_0
#imagegad_0
#img_1
#img_round1
#img_round2
#img_round3
#img_quad1
#img_quad2
#img_quad3
#img_se1
#img_se2
#img_se3
#img_maske_80x30
#img_sprverlauf
#img_verlauf1
EndEnumeration
IncludeFile "Prozeduren.pb"
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Arial", 8, #PB_Font_Bold)
CreateImage(#img_1,130,115)
StartDrawing(ImageOutput())
Box(0,0,130,115,RGB(255,255,255))
StopDrawing()
Procedure Open_Window_0()
If OpenWindow(#Window_0, 272, 146, 682, 227, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar |#PB_Window_ScreenCentered, "")
If CreateGadgetList(WindowID())
TextGadget(#Text_0, 15, 10, 120, 15, "Button-Vorlagen:")
SetGadgetFont(#Text_0, FontID1)
TextGadget(#Text_1, 15, 30, 120, 15, "Button-Form:")
SetGadgetFont(#Text_1, FontID1)
TextGadget(#Text_2, 15, 50, 140, 15, "Äußere Rahmenfarbe:")
SetGadgetFont(#Text_2, FontID1)
TextGadget(#Text_3, 15, 70, 140, 15, "Eck-Radius:")
SetGadgetFont(#Text_3, FontID1)
DisableGadget(#Text_3,1)
TextGadget(#Text_4, 15, 95, 120, 15, "Füllfarbe:")
SetGadgetFont(#Text_4, FontID1)
TextGadget(#text_back, 15, 115, 120, 15, "Hintergrundfarbe:")
SetGadgetFont(#text_back, FontID1)
TextGadget(#Text_5, 15, 135, 120, 15, "Button-Text:")
SetGadgetFont(#Text_5, FontID1)
TextGadget(#Text_6, 15, 155, 120, 15, "Textfarbe:")
SetGadgetFont(#Text_6, FontID1)
TextGadget(#Text_7, 15, 175, 120, 15, "Textfont:")
SetGadgetFont(#Text_7, FontID1)
ComboBoxGadget(#Combo_0, 160, 10, 130, 100)
SetGadgetFont(#Combo_0, FontID1)
ComboBoxGadget(#Combo_1, 160, 30, 130, 100)
;-Inhalt Combobox1
AddGadgetItem(#Combo_1,-1,"Rechteckig")
AddGadgetItem(#Combo_1,-1,"Sechseckig")
AddGadgetItem(#Combo_1,-1,"Abgerundet")
AddGadgetItem(#Combo_1,-1,"Abgerundet+Verlauf")
;-----
SetGadgetFont(#Combo_1, FontID1)
StringGadget(#String_0, 160, 50, 70, 20, "")
SetGadgetFont(#String_0, FontID1)
StringGadget(#String_1, 160, 90, 70, 20, "")
SetGadgetFont(#String_1, FontID1)
StringGadget(#string_back, 160, 110, 70, 20, "")
SetGadgetFont(#String_2, FontID1)
StringGadget(#String_2, 160, 130, 70, 20, "")
SetGadgetFont(#String_2, FontID1)
StringGadget(#String_3, 160, 150, 70, 20, "")
SetGadgetFont(#String_3, FontID1)
SpinGadget(#Spin_0, 160, 70, 80, 20, 0, 10)
DisableGadget(#Spin_0,1)
SetGadgetFont(#Spin_0, FontID1)
StringGadget(#String_5, 160, 170, 70, 20, "")
SetGadgetFont(#String_5, FontID1)
ButtonGadget(#Button_0, 235, 170, 110, 20, "Schrift Auswählen")
SetGadgetFont(#Button_0, FontID1)
ButtonGadget(#Button_1, 235, 50, 110, 20, "Farbe Auswählen")
SetGadgetFont(#Button_1, FontID1)
ButtonGadget(#Button_2, 235, 90, 110, 20, "Farbe Auswählen")
SetGadgetFont(#Button_2, FontID1)
ButtonGadget(#button_back, 235, 110, 110, 20, "Farbe Auswählen")
SetGadgetFont(#button_back, FontID1)
ButtonGadget(#Button_3, 235, 150, 110, 20, "Farbe Auswählen")
SetGadgetFont(#Button_3, FontID1)
Frame3DGadget(#Frame3D_0, 480, 35, 155, 140, "")
SetGadgetFont(#Frame3D_0, FontID1)
ImageGadget(#imagegad_0,493,50,130,115,UseImage(#img_1))
EndIf
EndIf
EndProcedure
;-----Prozeduren.pb-----
Procedure BlendBox(x.l,y.l,w.l,h.l,c1.l,c2.l)
r1 = Red(c1) ; Aufteilung Anfangsfarbe
g1 = Green(c1)
b1 = Blue(c1)
r2 = Red(c2) ; Aufteilung Zielfarbe
g2 = Green(c2)
b2 = Blue(c2)
rd.f = (r2-r1)/w ; Farbschritt pro Pixel
gd.f = (g2-g1)/w
bd.f = (b2-b1)/w
For n = 0 To w
FrontColor(r1+n*rd,g1+n*gd,b1+n*bd)
Line(x+n,y,0,h)
Next
EndProcedure
Procedure.s GetColorCode(color)
ProcedureReturn "#" + RSet(Hex(Red(color)), 2, "0") + RSet(Hex(Green(color)), 2, "0") + RSet(Hex(Blue(color)), 2, "0")
EndProcedure
Procedure Createimages(farbwert.l,fuellwert.l,back.l)
;-Rechteckiger Button
CreateImage(#img_quad1,80,30)
StartDrawing(ImageOutput())
col=GetSysColor_(#Window_0)
Box(0,0,80,30,col)
DrawingMode(4)
Box(0,0,80,30,farbwert)
DrawingMode(0)
FillArea(40,15,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(fuellwert), Green(fuellwert), Blue(fuellwert)))
StopDrawing()
;-sechseckiger Button
CreateImage(#img_quad2,80,30)
StartDrawing(ImageOutput())
Box(0,0,80,30,col)
DrawingMode(4)
FrontColor(Red(farbwert), Green(farbwert), Blue(farbwert))
Line(20,0,40,0)
Line(20,29,40,0)
Line(0,15,20,15)
Line(0,15,20,-15)
Line(60,1,20,15)
Line(60,29,20,-15)
DrawingMode(0)
FillArea(40,15,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(fuellwert), Green(fuellwert), Blue(fuellwert)))
StopDrawing()
;-Abgerundeter Button
CreateImage(#img_round1,80,30)
handle=StartDrawing(ImageOutput())
;col=GetSysColor_(#window_0)
Box(0,0,80,30,col)
DrawingMode(4)
FrontColor(Red(farbwert), Green(farbwert), Blue(farbwert))
roundrect_(handle,0,0,80,30,25,25)
DrawingMode(0)
FillArea(40,15,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(fuellwert), Green(fuellwert), Blue(fuellwert)))
FillArea(0,0,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(back), Green(back), Blue(back)))
FillArea(2,30,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(back), Green(back), Blue(back)))
FillArea(80,0,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(back), Green(back), Blue(back)))
FillArea(80,30,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(Red(back), Green(back), Blue(back)))
StopDrawing()
;-verlaufsmaske
CreateImage(#img_maske_80x30,80,30)
handle=StartDrawing(ImageOutput())
Box(0,0,80,30,col)
DrawingMode(4)
FrontColor(Red(farbwert), Green(farbwert), Blue(farbwert))
roundrect_(handle,0,0,80,30,25,25)
DrawingMode(0)
; FillArea(40,15,RGB(Red(farbwert), Green(farbwert), Blue(farbwert)),RGB(255,255,255))
StopDrawing()
;-verlauf
CreateImage(#img_sprverlauf,80,30)
StartDrawing(ImageOutput())
BlendBox(0,0,80,30,RGB(255,255,255),RGB(0,0,0))
StopDrawing()
EndProcedure