Legacy Samples · KcsDev1982/sunbelt-plb-samples@0c9afba · GitHub
Skip to content

Commit 0c9afba

Browse files
committed
Legacy Samples
Legacy samples originally release with PLBWIN
1 parent 2e829ab commit 0c9afba

95 files changed

Lines changed: 13322 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 0 deletions

legacy_demo/aclock.pls

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
. program to display an analog clock...
2+
. By Matthew Lake
3+
.
4+
. Rev history
5+
. Jul 26 2010 - added descriptive comments
6+
.
7+
. Program illustrates Higher math functions ( sin/cos )
8+
. APICALL
9+
. SHAPE
10+
. LINE
11+
. TIMER
12+
. EXCEPTSET
13+
.
14+
.-----borrowed from brian jackson
15+
GWL_EXSTYLE INTEGER 4,"0xFFFFFFEC"
16+
WS_EX_LAYERED INTEGER 4,"0x00080000"
17+
LWA_ALPHA INTEGER 4,"0x00000002"
18+
attributes INTEGER 4
19+
bytOpacity INTEGER 1,"128"
20+
byteZero INTEGER 1,"0"
21+
hWnd INTEGER 4
22+
23+
getWindowLong PROFILE !user32:
24+
GetWindowLongA:
25+
int4:
26+
int4:
27+
int4
28+
29+
setWindowLong PROFILE !user32:
30+
SetWindowLongA:
31+
int4:
32+
int4:
33+
int4:
34+
int4
35+
36+
setLayeredWindowAttributes PROFILE !user32:
37+
SetLayeredWindowAttributes:
38+
int4:
39+
int4:
40+
int1:
41+
int1:
42+
int4
43+
44+
#mwin WINDOW
45+
$CLOSE CONST "5"
46+
$RESIZE CONST "17"
47+
WINHIDE
48+
.
49+
. create a window that will contain the clock
50+
.
51+
CREATE #mwin=1:300:1:300,TOPMOST=1
52+
.
53+
. make the window transparent using APIs
54+
.
55+
GETPROP #mwin,hwnd=hwnd
56+
APICALL GetWindowLong giving attributes using hwnd,GWL_EXSTYLE
57+
OR WS_EX_LAYERED into attributes
58+
APICALL setWindowLong using hWnd,GWL_EXSTYLE,attributes
59+
APICALL setLayeredWindowAttributes using hWnd,byteZero,bytOpacity,LWA_ALPHA
60+
.
61+
. hook up desired events
62+
.
63+
EVENTREG #mwin,$CLOSE,term
64+
EVENTREG #mwin,$RESIZE,ShowClock
65+
.
66+
. create the clock on the window
67+
.
68+
CALL ShowClock using #mwin
69+
.
70+
. show the window AFTER everything is created and ready to display.
71+
.
72+
ACTIVATE #mwin
73+
.
74+
. wait for registered event to happen
75+
.
76+
LOOP
77+
EVENTWAIT
78+
REPEAT
79+
.
80+
. the $CLOSE event will end the program
81+
.
82+
term
83+
STOP
84+
85+
#Pi FORM "3.14159" ; constant PI needed for radiant calculation
86+
#work1 FORM 2.5
87+
#work2 FORM 2.5
88+
#hrs STATTEXT (12)
89+
#time TIMER
90+
#face SHAPE
91+
92+
#Win WINDOW ^
93+
#HideNum FORM 1
94+
ShowClock ROUTINE #Win,#HideNum
95+
#T FORM 4.5
96+
#B FORM 4.5
97+
#L FORM 4.5
98+
#R FORM 4.5
99+
#x FORM 2
100+
#label DIM 2
101+
#Color1 FORM "8421504" ;0x808080
102+
#Color2 FORM "12632256" ;0X404040
103+
#timeout FORM "10" ;This is a 1 second timeout
104+
105+
CLEAR #T,#L
106+
.
107+
. Get the size of the window that will contain the clock.
108+
.
109+
GETPROP #Win,WIDTH=#R,HEIGHT=#B
110+
.
111+
. create a circle for the clock face
112+
.
113+
CREATE #Win;#face=#T:#B:#L:#R,SHAPE=1,ZORDER=10,BGCOLOR=#Color1,FILLCOLOR=#Color2
114+
.
115+
. initial RADIANT values for 12 o'clock SIN and COS work in radians, not degrees.
116+
.
117+
CALC #work2=#pi/6
118+
CALC #work1=-(#work2*3) ;12 o'clock
119+
.
120+
. Clock Center
121+
.
122+
DIV "2",#R
123+
DIV "2",#B
124+
.
125+
IF ( #HideNum = "0" )
126+
FOR #x,"1","12"
127+
.
128+
ADD #work2,#work1 ; numeric position incrament
129+
SIN #work1,#T ; get x
130+
COS #work1,#L ; get y
131+
.
132+
MULT (#B-10),#T ; adjust for radius
133+
MULT (#R-10),#L
134+
ADD (#B-8),#T
135+
ADD (#R-4),#L
136+
.
137+
. create the stattext for the clock face numbers
138+
.
139+
MOVE #x,#label
140+
CREATE #Win;#hrs(#x)=#T:(#T+20):#L:(#L+20),#label:
141+
"'>MS Sans Serif'(8)":
142+
BACKSTYLE=2:
143+
ZORDER=11:
144+
USEALTKEY=1
145+
ACTIVATE #hrs(#x)
146+
REPEAT
147+
ENDIF
148+
.
149+
ACTIVATE #face
150+
.
151+
. create a timer object to continually update the displayed time
152+
.
153+
... MOVE "10",#timeout
154+
CREATE #win;#time,#timeout
155+
ACTIVATE #time,#UpdateClock,#timeout
156+
. RETURN ;fall through to update for initial positions
157+
158+
#HrHand LINE
159+
#MinHand LINE
160+
#SecHand LINE
161+
#tm DIM 15
162+
#hour FORM 2.4
163+
#min FORM 2.4
164+
#sec FORM 2.4
165+
..#R is left/right center
166+
..#B is top/Bottom center
167+
168+
#UpdateClock
169+
.
170+
EXCEPTSET StopClock if object
171+
.
172+
. get the current time to display
173+
.
174+
CLOCK TIME,#tm
175+
EXPLODE #tm,":",#hour,#min,#sec
176+
.
177+
. analog clocks only have a 12 hour display so adjust the hour if necessary
178+
.
179+
IF ( #hour > "12" )
180+
SUB "12",#hour
181+
ENDIF
182+
.
183+
. radiant position of hour + partial hour...
184+
.
185+
CALC #work1=("2"*#Pi)*(#hour/"12") + (#work2*(#min/"60")) - (#work2*3)
186+
SIN #work1,#T ; get x
187+
COS #work1,#L ; get y
188+
MULT (#B/2),#T ; adjust for radius
189+
MULT (#R/2),#L
190+
ADD (#B),#T
191+
ADD (#R),#L
192+
CREATE #Win;#HrHand=#B:#T:#R:#L,ZORDER=13,BDRWIDTH=5
193+
ACTIVATE #HrHand
194+
.
195+
. exact minute use..
196+
. MOVE (("2"*#Pi)*((#min/"60")) ),#work1 ; radiant position of minute
197+
. for partial minute position use this instead
198+
.
199+
CALC #work1=("2"*#Pi)*(#min/"60") + ((#work2/5)*(#sec/"60")) - (#work2*3)
200+
SIN #work1,#T ; get x
201+
COS #work1,#L ; get y
202+
MULT (#B*3/4),#T ; adjust for radius
203+
MULT (#R*3/4),#L
204+
ADD (#B),#T
205+
ADD (#R),#L
206+
CREATE #Win;#MinHand=#B:#T:#R:#L,ZORDER=14,BDRWIDTH=3
207+
ACTIVATE #MinHand
208+
.
209+
. finally, calculate the position for the second hand.
210+
.
211+
CALC #work1=(("2"*#Pi)*((#sec/"60")))-(#work2*3)
212+
SIN #work1,#T ; get x
213+
COS #work1,#L ; get y
214+
MULT (#B),#T ; adjust for radius
215+
MULT (#R),#L
216+
ADD (#B),#T
217+
ADD (#R),#L
218+
CREATE #Win;#SecHand=#B:#T:#R:#L,ZORDER=15,BDRWIDTH=1
219+
ACTIVATE #SecHand
220+
.
221+
EXCEPTCLEAR Object
222+
RETURN
223+
StopClock
224+
DESTROY #time
225+
RETURN

legacy_demo/addrform.plf

10.4 KB
Binary file not shown.

legacy_demo/addrform.pls

Lines changed: 121 additions & 0 deletions

0 commit comments

Comments
 (0)