Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.pls
More file actions
273 lines (272 loc) · 10.6 KB
/
color.pls
File metadata and controls
273 lines (272 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
*..........................................................................
.
.Example Program: COLOR.PLS
.
. This sample program is provided to help understand the RGB values which
. can be used for COLOR objects.
.
. Note: The actual colors which a given system displays is a function
. of the video driver and card in use. The colors displayed
. depends on wether 16, 256, or more colors are allowed.
.
. Copyright @ 1997, Sunbelt Computer Systems, Inc.
. All Rights Reserved.
*...........................................................................
.
LISTCOL DATALIST
LISTCOL1 DATALIST
COURIER FONT
TIMES FONT
STAT STATTEXT
STAT1 STATTEXT
STAT2 STATTEXT
COLOR COLOR
.
COLARR COLOR (12) ;12 element COLOR object array
.
BLACK COLOR ^,COLARR(1) ;COLOR pointers
BLUE COLOR ^,COLARR(2)
GREEN COLOR ^,COLARR(3)
CYAN COLOR ^,COLARR(4)
RED COLOR ^,COLARR(5)
MAGENTA COLOR ^,COLARR(6)
YELLOW COLOR ^,COLARR(7)
WHITE COLOR ^,COLARR(8)
GRAY COLOR ^,COLARR(9)
DKGRAY COLOR ^,COLARR(10)
LTGRAY COLOR ^,COLARR(11)
MDGRAY COLOR ^,COLARR(12)
.
DEFNAME DIM 10(12):
("*BLACK"):
("*BLUE"):
("*GREEN"):
("*CYAN"):
("*RED"):
("*MAGENTA"):
("*YELLOW"):
("*WHITE"):
("*GRAY"):
("*DKGRAY"):
("*LTGRAY"):
("*MDGRAY")
.
RGBFILE FILE BUFFER=4000
RGBREC LIST
XRED DIM 3
DIM1 DIM 1
XGREEN DIM 3
DIM1A DIM 1
XBLUE DIM 3
DIM12 DIM 12
XNAME DIM 25
LISTEND
.
FRED FORM 3
FGREEN FORM 3
FBLUE FORM 3
.
NRED FORM 3
NGREEN FORM 3
NBLUE FORM 3
.
CNT FORM 2
RESULT FORM 4
SEQ FORM "-1"
*.........................................................................
.
. Define the FONT objects used in the program
.
CREATE COURIER,"Courier"
CREATE TIMES,"Times New Roman"
*
. Create a default set of COLOR objects
. Note that this initialization not only initializes the COLARR elements,
. but also defines the COLOR object pointers declared in the UDA.
.
CREATE COLARR(1)=*BLACK
CREATE COLARR(2)=*BLUE
CREATE COLARR(3)=*GREEN
CREATE COLARR(4)=*CYAN
CREATE COLARR(5)=*RED
CREATE COLARR(6)=*MAGENTA
CREATE COLARR(7)=*YELLOW
CREATE COLARR(8)=*WHITE
CREATE COLARR(9)=*GRAY
CREATE COLARR(10)=*DKGRAY
CREATE COLARR(11)=*LTGRAY
CREATE COLARR(12)=*MDGRAY
.
CREATE COLOR=*RED ;Default for COLOR object
*
. Initialize the program controls and initialize the screen
.
SETMODE *LTGRAY=ON: ;Allow GRAY color substitued for YELLOW
*PIXEL=ON ;Program coordinates are PIXEL units
*
. Since *LTGRAY is on the *YELLOW is substituted as GRAY. Thus this statement
. paints the screen defined by the screen definition size as GRAY background.
.
DISPLAY *BGCOLOR=*YELLOW,*ES;
*
. Create a title STATTEXT field
.
CREATE STAT1=10:35:250:375: ;Coordinates are specified as PIXELS
"Color Sample Test": ;Title data to be displayed
TIMES: ;Times FONT object used
BGCOLOR=WHITE,STYLE=3DON:
BORDER ;Include border
ACTIVATE STAT1 // Activate the STATTEXT without any
// activation routine
*
. Create DATALIST object named 'LISTCOL' to hold RGB data records.
.
CREATE LISTCOL=50:200:50:225:
BGCOLOR=WHITE,STYLE=3DON:
FONT=COURIER:
SORTED ;Define DATALIST as sorted list
*
. Open RGB.TXT data file and load the DATA list with the RGB data
.
. The data stored into the DATALIST is the NAME, RED value, Green value, and
. Blue value.
.
OPEN RGBFILE,"rgb.txt",EXCLUSIVE
LOOP
READ RGBFILE,SEQ;RGBREC
BREAK IF OVER
SETLPTR XNAME
PACK S$CMDLIN,XNAME,XRED,XGREEN,XBLUE
INSERTITEM LISTCOL,9999,S$CMDLIN
REPEAT
.
ACTIVATE LISTCOL: ;DATALIST object being activated
XLISTCOL: ;Activation routine for object
RESULT ;Result passed to activation routine
*
. Create second DATALIST object named 'LISTCOL1' to hold default color
. selections.
.
CREATE LISTCOL1=203:400:50:225:
BGCOLOR=WHITE,STYLE=3DON:
FONT=COURIER ;Courier FONT object used
*
. Load the second DATALIST with the default color selections
.
MOVE "1",CNT
LOOP
SETLPTR DEFNAME(CNT)
INSERTITEM LISTCOL1,9999,DEFNAME(CNT)
ADD "1",CNT
COMPARE "13",CNT
REPEAT IF LESS
.
ACTIVATE LISTCOL1: ;DATALIST object being activated
XLISTCOL1: ;Activation routine for object
RESULT ;Result passed to activation routine
*
.Wait for an Event to Occur
.
LOOP
WAITEVENT
REPEAT
STOP
*...........................................................................
.
. This is the activation routine for the DATALIST object named LISTCOL.
. This routines performs the following basic functions:
.
. 1. Retrieves the data record specified in the DATALIST object.
. 2. Breaks the data record out into component variables.
. 3. Creates a COLOR object using the RED, GREEN, and BLUE values
. specified in the data record.
. 4. Retrieve COLOR object RGB values back using GETITEM.
. 5. Creates a STATTEXT object using the COLOR object for the background
. color.
. 6. Activate the STATTEXT object.
.
XLISTCOL
*
. Get the selected item from the DATALIST. The result passed to this
. activation routine is the number of the data list item selected by
. the user.
.
GETITEM LISTCOL,RESULT,S$CMDLIN
*
. Break the data list data out into the components variables.
.
UNPACK S$CMDLIN,XNAME,FRED,FGREEN,FBLUE
*
. Create a data variable with the necessary text to be placed into the
. STATTEXT object. This identifies the RGB component values to the user
. for the specified color.
.
PACK S$CMDLIN,"RED:",FRED," GREEN:",FGREEN," BLUE:",FBLUE
*
. Create the COLOR object with the RGB component values from the DATALIST
. record selected.
.
CREATE COLOR=FRED:FGREEN:FBLUE
*
. Having create the COLOR object, now we are showing that the RGB values
. can be retrieve from the COLOR using GETITEM.
.
. When the data field for the GETITEM is a numeric variable, then the
. the RED component is returned for an item number value of one. The
. GREEN component is returned for an item number value of two. The
. BLUE component is returned for an item number value of three.
.
LISTCOL2
GETITEM COLOR,1,NRED
GETITEM COLOR,2,NGREEN
GETITEM COLOR,3,NBLUE
*
. Create the STATTEXT object using the just created COLOR object as the
. background color.
.
CREATE STAT=50:75:250:425: ;Use PIXEL coordinates
S$CMDLIN: ;Text for the STATTEXT data
"'>MS Sans Serif'": ;Font used for the STATTEXT data
BGCOLOR=COLOR: ;Define the background color
STYLE=3DON:
BORDER ;Define a border to be used
ACTIVATE STAT // Activate the STATTEXT object
// without an activation routine.
*
. Create a STATTEXT object using the GETITEM RGB values.
.
PACK S$CMDLIN,"GETITEM VALUES:",NRED,"-",NGREEN,"-",NBLUE
CREATE STAT2=90:115:250:425: ;Use PIXEL coordinates
S$CMDLIN: ;Text for the STATTEXT data
"'>MS Sans Serif'": ;Font used for the STATTEXT data
BGCOLOR=WHITE:
STYLE=3DON:
BORDER ;Define a border to be used
ACTIVATE STAT2 // Activate the STATTEXT object
// without an activation routine.
RETURN
*...........................................................................
.
. This is the activation routine for the DATALIST object named 'LISTCOL1'.
. This routine uses an array of color objects to create the default
. color using the DATALIST selection number as the index.
.
XLISTCOL1
*
. Get name of DATALIST selected item
.
GETITEM LISTCOL1,RESULT,S$CMDLIN
*
. Change the COLOR object values using GETITEM and SETITEM.
.
GETITEM COLARR(RESULT),1,NRED
GETITEM COLARR(RESULT),2,NGREEN
GETITEM COLARR(RESULT),3,NBLUE
.
SETITEM COLOR,1,NRED
SETITEM COLOR,2,NGREEN
SETITEM COLOR,3,NBLUE
*
. Go output STATTEXT data
.
GOTO LISTCOL2
You can’t perform that action at this time.
