forked from 4D-JP/code-audit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_push_button_with_color.txt
159 lines (153 loc) · 5.62 KB
/
fix_push_button_with_color.txt
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
$resourcesFolderPath:=Get 4D folder(Current resources folder;*)
$imagesFolderDefaultName:="Images"
$imagesFolderSuffix:=0
$imagesFolderName:=$imagesFolderDefaultName
$imagesFolderPath:=""
Repeat
$imagesFolderPath:=$resourcesFolderPath+$imagesFolderName+Folder separator
$pathType:=Test path name($imagesFolderPath)
Case of
: ($pathType=Is a folder)
ARRAY TEXT($folders;0)
FOLDER LIST($imagesFolderPath;$folders)
If (Size of array($folders)#0)
$imagesFolderPath:=""
//continue
Else
ARRAY TEXT($files;0)
DOCUMENT LIST($imagesFolderPath;$files)
If (Size of array($files)#0)
$imagesFolderPath:=""
//continue
End if
End if
: ($pathType=Is a document)
$imagesFolderPath:=""
//continue
: ($pathType=-43)
//break
End case
If ($imagesFolderPath="")
$imagesFolderSuffix:=$imagesFolderSuffix+1
$imagesFolderName:=$imagesFolderDefaultName+" "+String($imagesFolderSuffix)
End if
Until ($imagesFolderPath#"")
CREATE FOLDER($imagesFolderPath;*)
$template:=""
If (True)
$svg:=DOM Create XML Ref("svg";"http://www.w3.org/2000/svg";"xmlns:xlink";"http://www.w3.org/1999/xlink")
DOM SET XML ATTRIBUTE($svg;"version";"1.1";"width";"$4DTEXT($1.strokeWidth+$1.width)";"height";"$4DTEXT(($1.strokeWidth*4)+($1.height*4))")
$defs:=DOM Create XML element($svg;"defs";"id";"defs")
$filter:=DOM Create XML element($defs;"filter";"id";"filter-disabled")
$feColorMatrix:=DOM Create XML element($filter;"feColorMatrix";\
"type";"matrix";"values";\
".299 .587 .114 0 0 "+\
".299 .587 .114 0 0 "+\
".299 .587 .114 0 0 "+\
".000 .000 .000 1 .000")
$filter:=DOM Create XML element($defs;"filter";"id";"filter-hover")
$feColorMatrix:=DOM Create XML element($filter;"feColorMatrix";\
"type";"matrix";"values";\
".888 0 0 0 0 0 "+\
".888 0 0 0 0 0 "+\
".888 0 0 0 0 0 "+\
"1 .000")
$filter:=DOM Create XML element($defs;"filter";"id";"filter-clicked")
$feColorMatrix:=DOM Create XML element($filter;"feColorMatrix";\
"type";"matrix";"values";\
".777 0 0 0 0 0 "+\
".777 0 0 0 0 0 "+\
".777 0 0 0 0 0 "+\
"1 .000")
$rect:=DOM Create XML element($defs;"rect";"id";"rect";\
"width";"$4DTEXT($1.width)";"height";"$4DTEXT($1.height)";\
"fill";"$4DTEXT($1.fill)";\
"stroke";"$4DTEXT($1.stroke)";"stroke-width";"$4DTEXT($1.strokeWidth)";\
"rx";"$4DTEXT($1.rx)";"ry";"$4DTEXT($1.ry)")
$rect:=DOM Create XML element($svg;"use";"href";"#rect";\
"x";"$4DTEXT($1.strokeWidth/2)";"y";"$4DTEXT($1.strokeWidth/2)")
$rect:=DOM Create XML element($svg;"use";"href";"#rect";\
"filter";"url(#filter-clicked)";\
"x";"$4DTEXT($1.strokeWidth/2)";"y";"$4DTEXT(($1.strokeWidth*1.5)+($1.height))")
$rect:=DOM Create XML element($svg;"use";"href";"#rect";\
"filter";"url(#filter-hover)";\
"x";"$4DTEXT($1.strokeWidth/2)";"y";"$4DTEXT(($1.strokeWidth*2.5)+($1.height*2))")
$rect:=DOM Create XML element($svg;"use";"href";"#rect";\
"filter";"url(#filter-disabled)";\
"x";"$4DTEXT($1.strokeWidth/2)";"y";"$4DTEXT(($1.strokeWidth*3.5)+($1.height*3))")
DOM EXPORT TO VAR($svg;$template)
DOM CLOSE XML($svg)
End if
$signature:=" // code added by "+Current method name+"\r"
If (True)
ARRAY TEXT($formNames;0)
For ($t;0;Get last table number)
If (Is table number valid($t)) | ($t=0)
If ($t#0)
FORM GET NAMES(Table($t)->;$formNames;*)
Else
FORM GET NAMES($formNames;*)
End if
For ($f;1;Size of array($formNames))
$formName:=$formNames{$f}
If ($t#0)
FORM LOAD(Table($t)->;$formName;*)
$methodPath:=METHOD Get path(Path table form;Table($t)->;$formName;*)
Else
FORM LOAD($formName;*)
$methodPath:=METHOD Get path(Path project form;$formName;*)
End if
FORM GET OBJECTS($objectNames;*)
$code:=""
METHOD GET CODE($methodPath;$code;Code with tokens;*)
$addCode:=(0=Position($signature;$code;*))
$codeSnippet:=""
If ($addCode)
$codeSnippet:=$signature
$codeSnippet:=$codeSnippet+"If (Form event:C388=On Load:K2:1)\r"
End if
For ($o;1;Size of array($objectNames))
$objectName:=$objectNames{$o}
$objectType:=OBJECT Get type(*;$objectName)
Case of
: ($objectType=Object type push button)
C_LONGINT($strokeColor;$fillColor;$left;$top;$right;$bottom)
OBJECT GET RGB COLORS(*;$objectName;$strokeColor;$fillColor)
OBJECT GET COORDINATES(*;$objectName;$left;$top;$right;$bottom)
$x:=$left
$y:=$top
$width:=$right-$left
$height:=$bottom-$top
$fill:="000000"+Substring(String($fillColor;"&x");3)
$fill:="#"+Substring($fill;Length($fill)-5)
$stroke:="000000"+Substring(String($strokeColor;"&x");3)
$stroke:="#"+Substring($stroke;Length($stroke)-5)
$params:=New object("width";$width;\
"height";$height;\
"fill";$fill;"stroke";$stroke;\
"strokeWidth";2;"rx";5;"ry";5)
PROCESS 4D TAGS($template;$svg;$params)
If ($t=0)
$tableName:="{projectForm}"
Else
$tableName:=Table name($t)
End if
$path:=$imagesFolderPath+$tableName+Folder separator+$objectName+".svg"
CREATE FOLDER($imagesFolderPath+$tableName+Folder separator;*)
TEXT TO DOCUMENT($path;$svg;"utf-8";Document with CRLF)
If ($addCode)
$format:=OBJECT Get format(*;$objectName)
$format:="\""+$format+";#;#"+$imagesFolderName+"/"+$tableName+"/"+$objectName+".svg;;1;0;4;;;;;;1"+"\""
$codeSnippet:=$codeSnippet+"OBJECT SET FORMAT:C236(*;\""+$objectName+"\";"+$format+")\r"
End if
End case
End for
If ($addCode)
$codeSnippet:=$code+"\r"+$codeSnippet+"End if\r"
METHOD SET CODE($methodPath;$codeSnippet;*)
End if
FORM UNLOAD
End for
End if
End for
End if