2- I did't test it with Mac or Linux
3- Adapt it for your needs
Have fun
Code: Select all
Global bHnd,Fcolor,Bcolor
Procedure Color_Button(bHnd,Fcolor,Bcolor)
SetGadgetColor(bHnd,#PB_Gadget_FrontColor, Fcolor)
SetGadgetColor(bHnd,#PB_Gadget_BackColor, Bcolor)
EndProcedure
LoadFont(0, "Marlett", 14)
OpenWindow(0,0,0,250,220,Space(24)+"Date & Time",#WS_DLGFRAME|#PB_Window_ScreenCentered)
SetWindowColor(0,$D9FFE7)
ContainerGadget(1,10,10,228,28,#PB_Container_Raised)
TextGadget(10,2,2,38,18,"Date :",#PB_Text_Center|#PB_Text_Border)
Color_Button(10,$FFFFFF,$000000)
TextGadget(11,44,2,38,18,"G",#PB_Text_Center|#PB_Text_Border)
Color_Button(11,$FF0000,$B0FFFF)
TextGadget(12,92,2,40,18,Str(Day(Date())),#PB_Text_Center|#PB_Text_Border)
Color_Button(12,$FF0000,$B0FFFF)
TextGadget(13,136,2,40,18,Str(Month(Date())),#PB_Text_Center|#PB_Text_Border)
Color_Button(13,$FF0000,$B0FFFF)
TextGadget(14,180,2,40,18,Str(Year(Date())),#PB_Text_Center|#PB_Text_Border)
Color_Button(14,$FF0000,$B0FFFF)
CloseGadgetList()
ContainerGadget(2,10,60,228,28,#PB_Container_Raised)
TextGadget(21,2,2,38,18,"Time :",#PB_Text_Center|#PB_Text_Border)
Color_Button(21,$FFFFFF,$000000)
If Hour(Date()) > 12
hour$ = Str(Hour(Date()) - 12)
hourc$ = "PM"
Else
hour$ = Str(Hour(Date()))
hourc$ = "AM"
EndIf
TextGadget(22,44,2,38,18,hourc$,#PB_Text_Center|#PB_Text_Border)
Color_Button(22,$0102FE,$B0FFFF)
TextGadget(23,92,2,40,18,hour$,#PB_Text_Center|#PB_Text_Border)
Color_Button(23,$0102FE,$B0FFFF)
TextGadget(24,136,2,40,18,Str(Minute(Date())),#PB_Text_Center|#PB_Text_Border)
Color_Button(24,$0102FE,$B0FFFF)
TextGadget(25,180,2,40,18,Str(Second(Date())),#PB_Text_Center|#PB_Text_Border)
Color_Button(25,$0102FE,$B0FFFF)
CloseGadgetList()
OptionGadget(30, 115, 38, 30, 20, "D")
OptionGadget(31, 160, 38, 30, 20, "M")
OptionGadget(32, 200, 38, 30, 20, "Y")
OptionGadget(33, 115, 88, 30, 20, "h")
OptionGadget(34, 160, 88, 30, 20, "m")
OptionGadget(35, 200, 88, 30, 20, "s")
CheckBoxGadget(38, 60, 88, 40,20," AM")
ButtonGadget(40, 105, 110,30,20,Chr(51))
SetGadgetFont(40, FontID(0))
ButtonGadget(41, 208, 110,30,20,Chr(52))
SetGadgetFont(41, FontID(0))
ButtonGadget(50, 4,170,60,20,"Quit")
ButtonGadget(51, 66,170,90,20,"Get Date")
ButtonGadget(52, 158,170,90,20,"Get Time")
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 40
For i = 30 To 35
If GetGadgetState(i) = 1
Break
EndIf
Next
If i = 30
If Val(GetGadgetText(12)) > 1
SetGadgetText(12,Str(Val(GetGadgetText(12))-1))
EndIf
ElseIf i = 31
If Val(GetGadgetText(13)) > 1
SetGadgetText(13,Str(Val(GetGadgetText(13))-1))
SetGadgetText(12,"1")
EndIf
ElseIf i = 32
If Val(GetGadgetText(14)) > 1
SetGadgetText(14,Str(Val(GetGadgetText(14))-1))
SetGadgetText(12,"1")
SetGadgetText(13,"1")
EndIf
ElseIf i = 33
If Val(GetGadgetText(23)) > 1
SetGadgetText(23,Str(Val(GetGadgetText(23))-1))
EndIf
ElseIf i = 34
If Val(GetGadgetText(24)) > 0
SetGadgetText(24,Str(Val(GetGadgetText(24))-1))
EndIf
ElseIf i = 35
If Val(GetGadgetText(25)) > 0
SetGadgetText(25,Str(Val(GetGadgetText(25))-1))
EndIf
EndIf
Case 41
If Val(GetGadgetText(13)) = 2
If Val(GetGadgetText(14))%4 = 0
md = 29
Else
md = 28
EndIf
ElseIf Val(GetGadgetText(13)) <> 2
om = Val(GetGadgetText(13))
If om = 1 Or om = 3 Or om = 5 Or om = 7 Or om = 8 Or om = 10 Or om = 12
md = 31
Else
md = 30
EndIf
EndIf
If Val(GetGadgetText(13)) = 2 And Val(GetGadgetText(12)) > md
SetGadgetText(12,Str(md))
EndIf
For i = 30 To 35
If GetGadgetState(i) = 1
Break
EndIf
Next
If i = 30
If Val(GetGadgetText(12)) < md
SetGadgetText(12,Str(Val(GetGadgetText(12))+1))
EndIf
ElseIf i = 31
If Val(GetGadgetText(13)) < 12
SetGadgetText(13,Str(Val(GetGadgetText(13))+1))
SetGadgetText(12,"1")
EndIf
ElseIf i = 32
If Val(GetGadgetText(14)) < 3000
SetGadgetText(14,Str(Val(GetGadgetText(14))+1))
SetGadgetText(12,"1")
SetGadgetText(13,"1")
EndIf
ElseIf i = 33
If Val(GetGadgetText(23)) < 12
SetGadgetText(23,Str(Val(GetGadgetText(23))+1))
EndIf
ElseIf i = 34
If Val(GetGadgetText(24)) < 60
SetGadgetText(24,Str(Val(GetGadgetText(24))+1))
EndIf
ElseIf i = 35
If Val(GetGadgetText(25)) < 60
SetGadgetText(25,Str(Val(GetGadgetText(25))+1))
EndIf
EndIf
Case 38
If GetGadgetState(38) = 1
SetGadgetText(22,"AM")
Else
SetGadgetText(22,"PM")
EndIf
Case 50
Quit = 1
Case 51
;Insert your code here for get date
Case 52
;Insert your code here for get time
EndSelect
EndSelect
Until Quit = 1