1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-15 11:59:34 +00:00
InForm/examples/WordClock/WordClock.bas

495 lines
8.4 KiB
QBasic
Raw Normal View History

2023-06-15 21:58:12 +00:00
': This program uses
': InForm - GUI library for QB64 - v1.0
': Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
': https://github.com/FellippeHeitor/InForm
'-----------------------------------------------------------
OPTION _EXPLICIT
2023-06-15 21:58:12 +00:00
': Controls' IDs: ------------------------------------------------------------------
DIM SHARED WordClock AS LONG
DIM SHARED ITISLB AS LONG
DIM SHARED HALFLB AS LONG
DIM SHARED TENLB AS LONG
DIM SHARED QUARTERLB AS LONG
DIM SHARED TWENTYLB AS LONG
DIM SHARED FIVELB AS LONG
DIM SHARED MINUTESLB AS LONG
DIM SHARED TOLB AS LONG
DIM SHARED PASTLB AS LONG
DIM SHARED TWOLB AS LONG
DIM SHARED THREELB AS LONG
DIM SHARED ONELB AS LONG
DIM SHARED FOURLB AS LONG
DIM SHARED FIVELB2 AS LONG
DIM SHARED SIXLB AS LONG
DIM SHARED SEVENLB AS LONG
DIM SHARED EIGHTLB AS LONG
DIM SHARED NINELB AS LONG
DIM SHARED TENLB2 AS LONG
DIM SHARED ELEVENLB AS LONG
DIM SHARED TWELVELB AS LONG
DIM SHARED OCLOCKLB AS LONG
DIM SHARED BackDots AS LONG
DIM SHARED DotsLB AS LONG
DIM SHARED Word(1 TO 22) AS LONG
2023-06-15 21:58:12 +00:00
': External modules: ---------------------------------------------------------------
'$INCLUDE:'../../InForm/InForm.bi'
2023-06-15 21:58:12 +00:00
'$INCLUDE:'WordClock.frm'
'$INCLUDE:'../../InForm/InForm.ui'
2023-06-15 21:58:12 +00:00
': Event procedures: ---------------------------------------------------------------
SUB __UI_BeforeInit
2023-06-15 21:58:12 +00:00
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_OnLoad
2023-06-15 21:58:12 +00:00
Word(1) = ITISLB
Word(2) = HALFLB
Word(3) = TENLB
Word(4) = QUARTERLB
Word(5) = TWENTYLB
Word(6) = FIVELB
Word(7) = MINUTESLB
Word(8) = TOLB
Word(9) = PASTLB
Word(10) = TWOLB
Word(11) = THREELB
Word(12) = ONELB
Word(13) = FOURLB
Word(14) = FIVELB2
Word(15) = SIXLB
Word(16) = SEVENLB
Word(17) = EIGHTLB
Word(18) = NINELB
Word(19) = TENLB2
Word(20) = ELEVENLB
Word(21) = TWELVELB
Word(22) = OCLOCKLB
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_BeforeUpdateDisplay
2023-06-15 21:58:12 +00:00
'This event occurs at approximately 30 frames per second.
'You can change the update frequency by calling SetFrameRate DesiredRate%
DIM i AS INTEGER, h AS INTEGER, m AS INTEGER
DIM dots AS INTEGER
STATIC prevH AS INTEGER, prevM AS INTEGER
2023-06-15 21:58:12 +00:00
h = VAL(LEFT$(TIME$, 2))
m = VAL(MID$(TIME$, 4, 2))
2023-06-15 21:58:12 +00:00
IF h = prevH AND m = prevM THEN EXIT SUB
2023-06-15 21:58:12 +00:00
prevH = h
prevM = m
switchOffAllWords
switchOn ITISLB
switchOn MINUTESLB
SELECT CASE m
CASE 0 TO 4
2023-06-15 21:58:12 +00:00
switchOn OCLOCKLB
switchOff MINUTESLB
dots = m
CASE 5 TO 9
2023-06-15 21:58:12 +00:00
switchOn FIVELB
switchOn PASTLB
dots = m - 5
CASE 10 TO 14
2023-06-15 21:58:12 +00:00
switchOn TENLB
switchOn PASTLB
dots = m - 10
CASE 15 TO 19
2023-06-15 21:58:12 +00:00
switchOn QUARTERLB
switchOff MINUTESLB
switchOn PASTLB
dots = m - 15
CASE 20 TO 24
2023-06-15 21:58:12 +00:00
switchOn TWENTYLB
switchOn PASTLB
dots = m - 20
CASE 25 TO 29
2023-06-15 21:58:12 +00:00
switchOn TWENTYLB
switchOn FIVELB
switchOn PASTLB
dots = m - 25
CASE 30 TO 34
2023-06-15 21:58:12 +00:00
switchOn HALFLB
switchOff MINUTESLB
switchOn PASTLB
dots = m - 30
CASE 35 TO 39
2023-06-15 21:58:12 +00:00
switchOn TWENTYLB
switchOn FIVELB
switchOn TOLB
dots = m - 35
CASE 40 TO 44
2023-06-15 21:58:12 +00:00
switchOn TWENTYLB
switchOn TOLB
dots = m - 40
CASE 45 TO 49
2023-06-15 21:58:12 +00:00
switchOn QUARTERLB
switchOff MINUTESLB
switchOn TOLB
dots = m - 45
CASE 50 TO 54
2023-06-15 21:58:12 +00:00
switchOn TENLB
switchOn TOLB
dots = m - 50
CASE 55 TO 59
2023-06-15 21:58:12 +00:00
switchOn FIVELB
switchOn TOLB
dots = m - 55
END SELECT
2023-06-15 21:58:12 +00:00
Caption(DotsLB) = ""
FOR i = 1 TO dots
2023-06-15 21:58:12 +00:00
Caption(DotsLB) = Caption(DotsLB) + "* "
NEXT
2023-06-15 21:58:12 +00:00
IF m >= 35 THEN
2023-06-15 21:58:12 +00:00
h = h + 1
END IF
2023-06-15 21:58:12 +00:00
SELECT CASE h
CASE 1, 13
2023-06-15 21:58:12 +00:00
switchOn ONELB
CASE 2, 14
2023-06-15 21:58:12 +00:00
switchOn TWOLB
CASE 3, 15
2023-06-15 21:58:12 +00:00
switchOn THREELB
CASE 4, 16
2023-06-15 21:58:12 +00:00
switchOn FOURLB
CASE 5, 17
2023-06-15 21:58:12 +00:00
switchOn FIVELB2
CASE 6, 18
2023-06-15 21:58:12 +00:00
switchOn SIXLB
CASE 7, 19
2023-06-15 21:58:12 +00:00
switchOn SEVENLB
CASE 8, 20
2023-06-15 21:58:12 +00:00
switchOn EIGHTLB
CASE 9, 21
2023-06-15 21:58:12 +00:00
switchOn NINELB
CASE 10, 22
2023-06-15 21:58:12 +00:00
switchOn TENLB2
CASE 11, 23
2023-06-15 21:58:12 +00:00
switchOn ELEVENLB
CASE 0, 12
2023-06-15 21:58:12 +00:00
switchOn TWELVELB
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB switchOffAllWords
DIM i AS INTEGER
FOR i = 1 TO UBOUND(Word)
2023-06-15 21:58:12 +00:00
switchOff Word(i)
NEXT
END SUB
2023-06-15 21:58:12 +00:00
SUB switchOn (this AS LONG)
2023-06-15 21:58:12 +00:00
Control(this).ForeColor = _RGB32(111, 205, 0)
Control(this).Redraw = TRUE
END SUB
2023-06-15 21:58:12 +00:00
SUB switchOff (this AS LONG)
2023-06-15 21:58:12 +00:00
Control(this).ForeColor = _RGB32(0, 39, 0)
Control(this).Redraw = TRUE
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_BeforeUnload
2023-06-15 21:58:12 +00:00
'If you set __UI_UnloadSignal = False here you can
'cancel the user's request to close.
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_Click (id AS LONG)
SELECT CASE id
CASE WordClock
2023-06-15 21:58:12 +00:00
CASE ITISLB
2023-06-15 21:58:12 +00:00
CASE HALFLB
2023-06-15 21:58:12 +00:00
CASE TENLB
2023-06-15 21:58:12 +00:00
CASE QUARTERLB
2023-06-15 21:58:12 +00:00
CASE TWENTYLB
2023-06-15 21:58:12 +00:00
CASE FIVELB
2023-06-15 21:58:12 +00:00
CASE MINUTESLB
2023-06-15 21:58:12 +00:00
CASE TOLB
2023-06-15 21:58:12 +00:00
CASE PASTLB
2023-06-15 21:58:12 +00:00
CASE TWOLB
2023-06-15 21:58:12 +00:00
CASE THREELB
2023-06-15 21:58:12 +00:00
CASE ONELB
2023-06-15 21:58:12 +00:00
CASE FOURLB
2023-06-15 21:58:12 +00:00
CASE FIVELB2
2023-06-15 21:58:12 +00:00
CASE SIXLB
2023-06-15 21:58:12 +00:00
CASE SEVENLB
2023-06-15 21:58:12 +00:00
CASE EIGHTLB
2023-06-15 21:58:12 +00:00
CASE NINELB
2023-06-15 21:58:12 +00:00
CASE TENLB2
2023-06-15 21:58:12 +00:00
CASE ELEVENLB
2023-06-15 21:58:12 +00:00
CASE TWELVELB
2023-06-15 21:58:12 +00:00
CASE OCLOCKLB
2023-06-15 21:58:12 +00:00
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_MouseEnter (id AS LONG)
SELECT CASE id
CASE WordClock
2023-06-15 21:58:12 +00:00
CASE ITISLB
2023-06-15 21:58:12 +00:00
CASE HALFLB
2023-06-15 21:58:12 +00:00
CASE TENLB
2023-06-15 21:58:12 +00:00
CASE QUARTERLB
2023-06-15 21:58:12 +00:00
CASE TWENTYLB
2023-06-15 21:58:12 +00:00
CASE FIVELB
2023-06-15 21:58:12 +00:00
CASE MINUTESLB
2023-06-15 21:58:12 +00:00
CASE TOLB
2023-06-15 21:58:12 +00:00
CASE PASTLB
2023-06-15 21:58:12 +00:00
CASE TWOLB
2023-06-15 21:58:12 +00:00
CASE THREELB
2023-06-15 21:58:12 +00:00
CASE ONELB
2023-06-15 21:58:12 +00:00
CASE FOURLB
2023-06-15 21:58:12 +00:00
CASE FIVELB2
2023-06-15 21:58:12 +00:00
CASE SIXLB
2023-06-15 21:58:12 +00:00
CASE SEVENLB
2023-06-15 21:58:12 +00:00
CASE EIGHTLB
2023-06-15 21:58:12 +00:00
CASE NINELB
2023-06-15 21:58:12 +00:00
CASE TENLB2
2023-06-15 21:58:12 +00:00
CASE ELEVENLB
2023-06-15 21:58:12 +00:00
CASE TWELVELB
2023-06-15 21:58:12 +00:00
CASE OCLOCKLB
2023-06-15 21:58:12 +00:00
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_MouseLeave (id AS LONG)
SELECT CASE id
CASE WordClock
2023-06-15 21:58:12 +00:00
CASE ITISLB
2023-06-15 21:58:12 +00:00
CASE HALFLB
2023-06-15 21:58:12 +00:00
CASE TENLB
2023-06-15 21:58:12 +00:00
CASE QUARTERLB
2023-06-15 21:58:12 +00:00
CASE TWENTYLB
2023-06-15 21:58:12 +00:00
CASE FIVELB
2023-06-15 21:58:12 +00:00
CASE MINUTESLB
2023-06-15 21:58:12 +00:00
CASE TOLB
2023-06-15 21:58:12 +00:00
CASE PASTLB
2023-06-15 21:58:12 +00:00
CASE TWOLB
2023-06-15 21:58:12 +00:00
CASE THREELB
2023-06-15 21:58:12 +00:00
CASE ONELB
2023-06-15 21:58:12 +00:00
CASE FOURLB
2023-06-15 21:58:12 +00:00
CASE FIVELB2
2023-06-15 21:58:12 +00:00
CASE SIXLB
2023-06-15 21:58:12 +00:00
CASE SEVENLB
2023-06-15 21:58:12 +00:00
CASE EIGHTLB
2023-06-15 21:58:12 +00:00
CASE NINELB
2023-06-15 21:58:12 +00:00
CASE TENLB2
2023-06-15 21:58:12 +00:00
CASE ELEVENLB
2023-06-15 21:58:12 +00:00
CASE TWELVELB
2023-06-15 21:58:12 +00:00
CASE OCLOCKLB
2023-06-15 21:58:12 +00:00
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_FocusIn (id AS LONG)
SELECT CASE id
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_FocusOut (id AS LONG)
2023-06-15 21:58:12 +00:00
'This event occurs right before a control loses focus.
'To prevent a control from losing focus, set __UI_KeepFocus = True below.
SELECT CASE id
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_MouseDown (id AS LONG)
SELECT CASE id
CASE WordClock
2023-06-15 21:58:12 +00:00
CASE ITISLB
2023-06-15 21:58:12 +00:00
CASE HALFLB
2023-06-15 21:58:12 +00:00
CASE TENLB
2023-06-15 21:58:12 +00:00
CASE QUARTERLB
2023-06-15 21:58:12 +00:00
CASE TWENTYLB
2023-06-15 21:58:12 +00:00
CASE FIVELB
2023-06-15 21:58:12 +00:00
CASE MINUTESLB
2023-06-15 21:58:12 +00:00
CASE TOLB
2023-06-15 21:58:12 +00:00
CASE PASTLB
2023-06-15 21:58:12 +00:00
CASE TWOLB
2023-06-15 21:58:12 +00:00
CASE THREELB
2023-06-15 21:58:12 +00:00
CASE ONELB
2023-06-15 21:58:12 +00:00
CASE FOURLB
2023-06-15 21:58:12 +00:00
CASE FIVELB2
2023-06-15 21:58:12 +00:00
CASE SIXLB
2023-06-15 21:58:12 +00:00
CASE SEVENLB
2023-06-15 21:58:12 +00:00
CASE EIGHTLB
2023-06-15 21:58:12 +00:00
CASE NINELB
2023-06-15 21:58:12 +00:00
CASE TENLB2
2023-06-15 21:58:12 +00:00
CASE ELEVENLB
2023-06-15 21:58:12 +00:00
CASE TWELVELB
2023-06-15 21:58:12 +00:00
CASE OCLOCKLB
2023-06-15 21:58:12 +00:00
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_MouseUp (id AS LONG)
SELECT CASE id
CASE WordClock
2023-06-15 21:58:12 +00:00
CASE ITISLB
2023-06-15 21:58:12 +00:00
CASE HALFLB
2023-06-15 21:58:12 +00:00
CASE TENLB
2023-06-15 21:58:12 +00:00
CASE QUARTERLB
2023-06-15 21:58:12 +00:00
CASE TWENTYLB
2023-06-15 21:58:12 +00:00
CASE FIVELB
2023-06-15 21:58:12 +00:00
CASE MINUTESLB
2023-06-15 21:58:12 +00:00
CASE TOLB
2023-06-15 21:58:12 +00:00
CASE PASTLB
2023-06-15 21:58:12 +00:00
CASE TWOLB
2023-06-15 21:58:12 +00:00
CASE THREELB
2023-06-15 21:58:12 +00:00
CASE ONELB
2023-06-15 21:58:12 +00:00
CASE FOURLB
2023-06-15 21:58:12 +00:00
CASE FIVELB2
2023-06-15 21:58:12 +00:00
CASE SIXLB
2023-06-15 21:58:12 +00:00
CASE SEVENLB
2023-06-15 21:58:12 +00:00
CASE EIGHTLB
2023-06-15 21:58:12 +00:00
CASE NINELB
2023-06-15 21:58:12 +00:00
CASE TENLB2
2023-06-15 21:58:12 +00:00
CASE ELEVENLB
2023-06-15 21:58:12 +00:00
CASE TWELVELB
2023-06-15 21:58:12 +00:00
CASE OCLOCKLB
2023-06-15 21:58:12 +00:00
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_KeyPress (id AS LONG)
2023-06-15 21:58:12 +00:00
'When this event is fired, __UI_KeyHit will contain the code of the key hit.
'You can change it and even cancel it by making it = 0
SELECT CASE id
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_TextChanged (id AS LONG)
SELECT CASE id
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_ValueChanged (id AS LONG)
SELECT CASE id
END SELECT
END SUB
2023-06-15 21:58:12 +00:00
SUB __UI_FormResized
2023-06-15 21:58:12 +00:00
END SUB