-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnfthemes.PRG
283 lines (205 loc) · 6.51 KB
/
nfthemes.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
*******************************************************
* Marco Plaza, 2022 * @nfoxdev
* visualfoxpro color preferences v1.2.0
* https://github.com/nfoxdev/nfthemes
*******************************************************
#Define crlf Chr(13)+Chr(10)
#Define themeextension 'vfptheme'
Set Path To (Justpath(Sys(16))) Additive
_Screen.AddProperty('nfthemes',Createobject('nfThemes'))
*************************************
Define Class nfthemes As Form
*************************************
ShowWindow = 2
BorderStyle = 0
MaxButton = .F.
MinButton = .F.
AutoCenter = .T.
AlwaysOnTop = .T.
Width = 350
Height = 450+40
Caption = 'nfTools - ( Click=FontColor RightClick=BackColor )'
BackColor = Rgb(100,100,100)
ShowTips = .T.
foxreg = .F.
oldinireg = .F.
Add Object savetheme As CommandButton With Caption='Save Theme',Visible = .T.,Top=4,Left=10,Height=20,Width=150
Add Object loadtheme As CommandButton With Caption='Load Theme',Visible = .T.,Top=4,Left=190,Height=20,Width=150
Add Object pf As PageFrame With ;
left = 2, Top = 25,Height = 410,Width=348,;
themes=.F.,TabStyle=0,SpecialEffect=0,TabStretch=0,;
borderwidth=0,PageCount=10
*--------------------------
Function Init()
*--------------------------
Local nexttop
Local kn
Local ntab
Local Array atabnames(1)
TEXT TO colorsCsv NOSHOW PRETEXT 2+4+8
EditorNormalColor,EditorVariableColor,EditorCommentColor,EditorKeyWordColor,EditorOperatorColor,EditorConstantColor,EditorStringColor,
TraceNormalColor,TraceExecutingColor,TraceCallStackColor,
TraceBreakpointColor,TraceSelectedColor,
WatchNormalColor,WatchSelectedColor,WatchChangedColor,
LocalsNormalColor,LocalsSelectedColor,
OutputNormalColor,OutputSelectedColor,
CallstackNormalColor,CallstackSelectedColor,
BookmarkColor,ShortcutColor
ENDTEXT
AddProperty(This,'colorKeys(1)',.Null.)
Alines(This.colorkeys,m.colorscsv,1,',')
This.foxreg = Newobject('foxreg','registry.prg')
This.oldinireg = Newobject('oldinireg','registry.prg')
This.pf.PageCount = Alines(atabnames,'Editor,Trace,Locals,Watch,Output,Callstack,Bookmark,Shortcut',1,',')
For ntab = 1 To This.pf.PageCount
nexttop = 10
With This.pf.Pages(m.ntab)
.Caption = atabnames(m.ntab)
.BackColor = Rgb(100,100,100)
.ForeColor = Rgb(255,255,255)
For Each kn In This.colorkeys
If m.kn = .Caption
.AddObject(m.kn,'colorlbl',m.kn,m.nexttop)
nexttop = m.nexttop + .&kn..Height + 3
Endif
Endfor
Endwith
Endfor
This.Visible = .T.
*-----------------------------------------------
Procedure savetheme.Click()
*-----------------------------------------------
Local cfile
Local Page
Local pp
Local Array albl(1)
cfile = Putfile('Save Theme as','my preferences',themeextension)
If !Empty(m.cfile)
Thisform.dosavetheme(m.cfile)
Endif
*----------------------------------------------
Procedure dosavetheme(m.cfile)
*----------------------------------------------
cfile = Forceext(m.cfile,themeextension)
Strtofile('[vfp9colors]'+crlf,m.cfile)
For Each Page In Thisform.pf.Pages As PageFrame
Amembers(albl,m.page,2,'U')
For Each pp In albl
Strtofile( Proper(m.pp)+' = '+m.page.&pp..regkey+crlf,m.cfile,1)
Endfor
Endfor
Messagebox('Theme saved as '+crlf+m.cfile,0,'nfThemes')
*-----------------------------------------------
Procedure loadtheme.Click()
*-----------------------------------------------
Local cfile
Local oldinireg
Local Value
Local colorkey
Local Page
Local pp
Local Array albl(1)
cfile = Getfile(themeextension,'Load VFP colors')
If File(m.cfile)
For Each colorkey In Thisform.colorkeys
Value = ''
Thisform.oldinireg.getinientry(@m.value,'vfp9colors',m.colorkey,m.cfile)
Thisform.foxreg.setfoxoption(m.colorkey,m.value)
Endfor
For Each Page In Thisform.pf.Pages As PageFrame
Amembers(albl,m.page,2,'U')
For Each pp In albl
m.page.&pp..setcolorfromreg()
Endfor
Endfor
Sys(3056)
Messagebox('Theme '+Justfname(m.cfile)+' loaded',0,'nfThemes')
Endif
*****************************************
Enddefine
******************************************
*******************************************
Define Class colorlbl As Label
*******************************************
Visible = .T.
FontSize = 12
FontName = 'Segoe UI'
Alignment = 2
foxreg = .F.
Height = 50
Left = 10
SpecialEffect=2
colorkeyname= ''
fontkeyname=''
regkey = ''
*-----------------------------------------------------------
Procedure Init( colorkeyname,Top)
*----------------------------------------------------------
Local regval
With This
.Caption = m.colorkeyname
.colorkeyname = m.colorkeyname
.Top = m.top
.Width = Thisform.Width-20
.ToolTipText = m.colorkeyname
.setcolorfromreg()
Endwith
*-------------------------------------
Function setcolorfromreg()
*-------------------------------------
Local regval
regval = ''
Thisform.foxreg.getfoxoption(This.Caption,@regval)
Local Array ac(1)
If Alines(ac,Strextract(m.regval,'RGB(',')',1,1),1,',') # 6
Dimension ac(6)
Store '0' To ac(1),ac(2),ac(3)
Store '255' To ac(4),ac(5),ac(6)
Endif
With This
.ForeColor = Rgb(&ac(1),&ac(2),&ac(3))
.BackColor = Rgb(&ac(4),&ac(5),&ac(6))
.regkey = m.regval
Endwith
*----------------------------------------------------------
Function MouseUp(nbutton, nshift, nxcoord, nycoord)
*----------------------------------------------------------
Local newcolor
Local csp
Local fred,fgreen,fblue,bred,bgreen,bblue
Local tt,tc
If m.nbutton=1
tt = ' ForeColor'
tc = This.ForeColor
Else
tt = ' BackColor'
tc = This.BackColor
Endif
Wait Textmerge('Pick <<m.tt>> For <<rtrim(this.colorKeyName,1,"color")>>') Window Nowait
newcolor = Getcolor(m.tc)
If m.newcolor = -1
Return
Endif
If m.nbutton=1
This.ForeColor = m.newcolor
Else
This.BackColor = m.newcolor
Endif
Store '' To fred,fgreen,fblue,bred,bgreen,bblue
This.color2rgb( This.ForeColor, @m.fred,@m.fgreen,@m.fblue)
This.color2rgb( This.BackColor, @m.bred,@m.bgreen,@m.bblue)
This.regkey = Textmerge('RGB(<<m.fred>>,<<m.fgreen>>,<<m.fblue>>,<<m.bred>>,<<m.bgreen>>,<<m.bblue>>), NoAuto, NoAuto')
Thisform.foxreg.setfoxoption(This.colorkeyname,This.regkey)
Local csp
csp = Set('path')
Sys(3056)
Set Path To (m.csp)
*---------------------------------------------------
Procedure color2rgb( tncolor, r , g, b )
*---------------------------------------------------
r = Bitrshift(Bitand(tncolor, 0x0000ff),0)
g = Bitrshift(Bitand(tncolor, 0x00ff00),8)
b = Bitrshift(Bitand(tncolor, 0xff0000),16)
******************************************
Enddefine
******************************************