This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLR_CLS.PRG
250 lines (206 loc) · 6.72 KB
/
CLR_CLS.PRG
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
/*
* PRG...............: CLR_CLS.PRG
* INCLUDE...........: CLR_CLS.CH
* DATABASE FILES....: COLORS.DBF
* STRUCTURE.........: "CODE" N 2
* "VALUE" C 15
*
* CLASS.............: Color settings management Class
* DESC..............: Gets, Stores & Provides Color Settings
* EXPORTS...........: Nil
* CONSTRUCTOR.......: NewColor ()
* METHODS...........: ColorChange ()
* STATIC FUNCTIONS..: ReadColor(), WriteColor(),
* DefaultColor() & ChangeColor()
*
* USES..............: Standard Clipper Functions
* Stack Class - STK_CLS.PRG.
*
* NOTES.............: The Constructor returns a object, which
* contains one code block and elements which
* have color options.
*
* AUTHOR............: venkata rangan, tnc
* DATE..............: 20-04-1995
* PROJECT...........: Alankar Travels Billing Program.
*
* COMPILER..........: CA-Clipper 5.2
* SWITCHES..........: /n /w /m
*/
#include "Clr_Cls.Ch"
#include "Apply.Ch"
#include "Box.Ch"
FUNCTION NewColor
LOCAL oClr
// reading a color from database, if failed from default
oClr := ReadColor ()
// this is a method, oClr:ColorChange()
AADD(oClr, { |o| ChangeColor (o) } )
RETURN oClr
/*
* This function is visible only in this program
* Gives the default colors as an Object
*/
STATIC FUNCTION DefaultColor
LOCAL oClr[CLR_SIZE]
oClr:WndTitle := "n/w"
oClr:WndText := "w/r"
oClr:WndBox := "w/b"
oClr:ScrollBar := "n/w"
oClr:MenuText1 := "w+/b" // Normal,Inactive color
oClr:MenuText2 := "n/w" // Reverse, Active Color
oClr:MenuText := oClr:MenuText1+','+oClr:MenuText2
oClr:MenuBox := "rg+/b"
oClr:Buttons1 := "w/n" // Normal, Inactive color
oClr:Buttons2 := "w+/b"// Reverse, Active Color
oClr:Buttons := oClr:Buttons1 + ','+oClr:Buttons2
oClr:MsgTitle := "W+/GR"
oClr:MsgText := "b/w"
oClr:MsgBox := "n/w"
oClr:TitleBar := "b/bg"
oClr:Desktop := "w/b"
oClr:ShowScr := "rg+/b"
oClr:EditScr := "n/w"
oClr:WorkSpace := oClr:ShowScr + ','+oClr:EditScr
//oClr:Show + oClr:Edit will give you the WorkSpace color
oClr:HelpLine := "b/w"
oClr:HelpBox := "n/w"
oClr:HelpText := "w+/n"
RETURN oClr
/*
* This function is visible only in this program
* Reads the colors from a database called colors.dbf,
* if database fails from defaultcolor function.
*/
STATIC FUNCTION ReadColor
LOCAL oClr[CLR_SIZE], oStack := NewStack()
Push (oStack, SELECT ())
// if file is not found, create a new one
IF FILE ("Colors.Dbf")
SELECT 0
USE Colors
DBEVAL ( {| | oClr[Colors->Code] := Colors->Value} )
oClr:MenuText := oClr:MenuText1+','+oClr:MenuText2
oClr:Buttons := oClr:Buttons1 + ','+oClr:Buttons2
oClr:WorkSpace := oClr:ShowScr + ','+oClr:EditScr
USE
DBSELECTAR (Pop(oStack))
ELSE
ALERT ("COLORS.DBF file is missing, using default Colors")
oClr := DefaultColor()
ENDIF
RETURN oClr
/*
* This function is visible only in this program
* Writes the colors into the database file Colors.Dbf,
* returns .T. if mission successful, if not returns .F.
*/
STATIC PROCEDURE WriteColor (oClr)
LOCAL oStack := NewStack(), I
//save the database informations
Push (oStack, SELECT ())
// if file is not found, create a new one
IF FILE ("Colors.Dbf")
// file is found
ELSE
ALERT ("COLORS.DBF file is missing, creating a new one")
DBCREATE ("Colors",{ {"Code", "N", 2, 0},{"Value","C",15,0}} )
ENDIF
SELECT 0
USE Colors
ZAP
FOR I := 1 TO CLR_SIZE
DBAPPEND()
Colors->Code := I
Colors->Value := oClr[I]
NEXT
USE
//restore the database informations
DBSELECTAR (Pop (oStack))
RETURN
/*
* This function is visible only in this program
* Interacts with the user and changes colors and calls
* WriteColor function to write it. If failed reports,
* to user.
* Returns the New Color Object or Default Color object
* F5 - SAVE SETTINGS
* F6 - DEFAULT COLORS
*/
STATIC FUNCTION ChangeColor (oClr)
LOCAL oStack := NewStack()
LOCAL nChoice :=1, nClr
LOCAL aModuleText := { "Default Colors", "Save Colors",;
"Window Title", "Window Text", "Windows Box",;
"Message Title", "Message Text", "Message Box",;
"Desk top","Get Areas","Say Areas",;
"Active Buttons","Inactive Buttons", "Active Menu",;
"Inactive Menu", "Menu Box", "TitleBar",;
"Help line", "Help Text", "Help Box",;
"Scroll Bar"}
LOCAL aModuleId := { WNDTITLE, WNDTEXT, WNDBOX, ;
MSGTITLE, MSGTEXT, MSGBOX, ;
DESKTOP, EDITSCR, SHOWSCR, ;
BUTTONS2, BUTTONS1, MENUTEXT2, ;
MENUTEXT1, MENUBOX, TITLEBAR, ;
HELPLINE, HELPTEXT, HELPBOX, ;
SCROLLBAR }
Push (oStack, SETCOLOR ("n/w,w/n"))
Push (oStack, SETCURSOR (1) ) // Normal Cursor
Push (oStack, SAVESCREEN (5,10,20,30) )
Push (oStack, SETKEY ( 19, { | | Inkey() }) ) // left arrow
Push (oStack, SETKEY ( 4, { | | Inkey() }) ) // right arrow
@ 5,10,20,30 BOX B_DOUBLE + " "
@ 6,15 SAY "Modules"
@ 7,10 SAY 'Ç'
@ 7,11,7,29 BOX REPL('Ä',8)
@ 7,30 SAY '¶'
// swallow left and right
DO WHILE .T.
nChoice := ACHOICE (8,13,19,27,aModuleText)
DO CASE
CASE nChoice == 0
EXIT
CASE nChoice == 1
oClr := DefaultColor()
CASE nChoice == 2
WriteColor ( oClr )
OTHERWISE
nChoice := nChoice - 2 // used up for default & Save
oClr[aModuleId[nChoice]] := ColorSelect(oClr[aModuleId[nChoice]])
oClr:Buttons := oClr:Buttons1 + ',' + oClr:Buttons2
oClr:MenuText := oClr:MenuText1 + ',' + oClr:MenuText2
oClr:WorkSpace := oClr:ShowScr + ',' + oClr:EditScr
ENDCASE
ENDDO
SETKEY (4, Pop(oStack))
SETKEY (19, Pop(oStack))
RESTSCREEN (5,10,20,30, Pop (oStack))
SETCURSOR (Pop(oStack))
SETCOLOR (Pop(oStack))
RETURN oClr
STATIC FUNCTION ColorSelect (cCargo)
LOCAL nrow := ROW()
LOCAL oStack := NewStack()
LOCAL aClrText := { 'Black','White', 'Blue','Red','Green',;
'Yellow', 'Cyan', 'Magenta', 'Brown',;
'Gray','Bright White','Bright Magenta'}
LOCAL aClrVal := { 'N','W','B','R','G','GR+','BG','RB','GR',;
'N+','W+','RB+' }
LOCAL a,b
Push (oStack, SETKEY ( 27, { | | Inkey() }) )
Push (oStack, SAVESCREEN (5,50,20,71) )
@ nrow, 10 SAY "-->"
@ 5,50,20,71 BOX B_DOUBLE +" "
@ 6,52 SAY "Fore Ground Colors"
@ 7,50 SAY 'Ç'
@ 7,51,7,70 BOX REPL('Ä',8)
@ 7,71 SAY '¶'
a := ACHOICE (8,53,19,68,aClrText)
@ 6,52 SAY "Back Ground Colors"
b := ACHOICE (8,53,19,68,aClrText)
cCargo := aClrVal[a] + '/' + aClrVal[b]
@ nrow,10 SAY "º "
RESTSCREEN (5,50,20,71, Pop(oStack))
SETKEY (27, Pop(oStack))
RETURN cCargo