| 1 |
# An FvwmScript GUI to change colorsets |
| 2 |
# I can't believe how big this is |
| 3 |
# I haven't got the energy to implement a Save button |
| 4 |
# Just goes to show that command lines are better |
| 5 |
# Don't switch on Dynamic update unless using ReadWriteColors |
| 6 |
WindowTitle {Colorset Editor} |
| 7 |
WindowSize 380 290 |
| 8 |
Colorset 0 |
| 9 |
|
| 10 |
Init |
| 11 |
Begin |
| 12 |
# This is the colorset being worked on |
| 13 |
Set $Cset = 0 |
| 14 |
Set $OldCset = 0 |
| 15 |
Set $Color = (GetBack 1) |
| 16 |
Do {Colorset } $Cset { Pixmap, Background #} $Color {, Foreground Contrast} |
| 17 |
# Sliders are initially hidden |
| 18 |
HideWidget 1 |
| 19 |
HideWidget 2 |
| 20 |
HideWidget 3 |
| 21 |
HideWidget 21 |
| 22 |
HideWidget 22 |
| 23 |
HideWidget 23 |
| 24 |
End |
| 25 |
|
| 26 |
# radio buttons to pick the colorset aspect to change |
| 27 |
Widget 13 |
| 28 |
Property |
| 29 |
Position 120 10 |
| 30 |
Type RadioButton |
| 31 |
Title {Background} |
| 32 |
Main |
| 33 |
Case message of |
| 34 |
SingleClic : |
| 35 |
Begin |
| 36 |
Set $Color = (GetBack 1) |
| 37 |
ChangeValue 1 (HexToNum (StrCopy $Color 1 2)) |
| 38 |
ChangeValue 2 (HexToNum (StrCopy $Color 3 4)) |
| 39 |
ChangeValue 3 (HexToNum (StrCopy $Color 5 6)) |
| 40 |
ChangeValue 10 0 |
| 41 |
ChangeValue 11 0 |
| 42 |
ChangeValue 12 0 |
| 43 |
ShowWidget 1 |
| 44 |
ShowWidget 2 |
| 45 |
ShowWidget 3 |
| 46 |
ShowWidget 21 |
| 47 |
ShowWidget 22 |
| 48 |
ShowWidget 23 |
| 49 |
End |
| 50 |
End |
| 51 |
|
| 52 |
Widget 10 |
| 53 |
Property |
| 54 |
Position 220 10 |
| 55 |
Type RadioButton |
| 56 |
Title {Foreground} |
| 57 |
Main |
| 58 |
Case message of |
| 59 |
SingleClic : |
| 60 |
Begin |
| 61 |
Set $Color = (GetFore 1) |
| 62 |
ChangeValue 1 (HexToNum (StrCopy $Color 1 2)) |
| 63 |
ChangeValue 2 (HexToNum (StrCopy $Color 3 4)) |
| 64 |
ChangeValue 3 (HexToNum (StrCopy $Color 5 6)) |
| 65 |
ChangeValue 11 0 |
| 66 |
ChangeValue 12 0 |
| 67 |
ChangeValue 13 0 |
| 68 |
ShowWidget 1 |
| 69 |
ShowWidget 2 |
| 70 |
ShowWidget 3 |
| 71 |
ShowWidget 21 |
| 72 |
ShowWidget 22 |
| 73 |
ShowWidget 23 |
| 74 |
End |
| 75 |
End |
| 76 |
|
| 77 |
Widget 11 |
| 78 |
Property |
| 79 |
Position 120 30 |
| 80 |
Type RadioButton |
| 81 |
Title {Hilite} |
| 82 |
Main |
| 83 |
Case message of |
| 84 |
SingleClic : |
| 85 |
Begin |
| 86 |
Set $Color = (GetHilight 1) |
| 87 |
ChangeValue 1 (HexToNum (StrCopy $Color 1 2)) |
| 88 |
ChangeValue 2 (HexToNum (StrCopy $Color 3 4)) |
| 89 |
ChangeValue 3 (HexToNum (StrCopy $Color 5 6)) |
| 90 |
ChangeValue 10 0 |
| 91 |
ChangeValue 12 0 |
| 92 |
ChangeValue 13 0 |
| 93 |
ShowWidget 1 |
| 94 |
ShowWidget 2 |
| 95 |
ShowWidget 3 |
| 96 |
ShowWidget 21 |
| 97 |
ShowWidget 22 |
| 98 |
ShowWidget 23 |
| 99 |
End |
| 100 |
End |
| 101 |
|
| 102 |
Widget 12 |
| 103 |
Property |
| 104 |
Position 220 30 |
| 105 |
Type RadioButton |
| 106 |
Title {Shadow} |
| 107 |
Main |
| 108 |
Case message of |
| 109 |
SingleClic : |
| 110 |
Begin |
| 111 |
Set $Color = (GetShadow 1) |
| 112 |
ChangeValue 1 (HexToNum (StrCopy $Color 1 2)) |
| 113 |
ChangeValue 2 (HexToNum (StrCopy $Color 3 4)) |
| 114 |
ChangeValue 3 (HexToNum (StrCopy $Color 5 6)) |
| 115 |
ChangeValue 10 0 |
| 116 |
ChangeValue 11 0 |
| 117 |
ChangeValue 13 0 |
| 118 |
ShowWidget 1 |
| 119 |
ShowWidget 2 |
| 120 |
ShowWidget 3 |
| 121 |
ShowWidget 21 |
| 122 |
ShowWidget 22 |
| 123 |
ShowWidget 23 |
| 124 |
End |
| 125 |
End |
| 126 |
|
| 127 |
# colorset selector |
| 128 |
# miniscrolls clic on button press and release hence the (div x 2) |
| 129 |
# and they roll over which is bad for defining colorsets |
| 130 |
Widget 4 |
| 131 |
Property |
| 132 |
Position 10 10 |
| 133 |
Type MiniScroll |
| 134 |
Value 0 |
| 135 |
MinValue 0 |
| 136 |
MaxValue 101 |
| 137 |
Main |
| 138 |
Case message of |
| 139 |
SingleClic : |
| 140 |
Begin |
| 141 |
# hold at max value |
| 142 |
If (GetValue 4) == 100 Then |
| 143 |
ChangeValue 4 99 |
| 144 |
# hold at min value |
| 145 |
If (GetValue 4) > 100 Then |
| 146 |
ChangeValue 4 0 |
| 147 |
Set $OldCset = $Cset |
| 148 |
Set $Cset = (Div (GetValue 4) 2) |
| 149 |
Set $CsetName = {Colorset } $Cset |
| 150 |
ChangeTitle 5 $CsetName |
| 151 |
# redisplay in new colorset |
| 152 |
ChangeColorset 0 $Cset |
| 153 |
ChangeColorset 1 $Cset |
| 154 |
ChangeColorset 2 $Cset |
| 155 |
ChangeColorset 3 $Cset |
| 156 |
ChangeColorset 4 $Cset |
| 157 |
ChangeColorset 5 $Cset |
| 158 |
ChangeColorset 6 $Cset |
| 159 |
ChangeColorset 7 $Cset |
| 160 |
ChangeColorset 10 $Cset |
| 161 |
ChangeColorset 11 $Cset |
| 162 |
ChangeColorset 12 $Cset |
| 163 |
ChangeColorset 13 $Cset |
| 164 |
ChangeColorset 21 $Cset |
| 165 |
ChangeColorset 22 $Cset |
| 166 |
ChangeColorset 23 $Cset |
| 167 |
ChangeColorset 0 $Cset |
| 168 |
# unselect all radio buttons |
| 169 |
ChangeValue 10 0 |
| 170 |
ChangeValue 11 0 |
| 171 |
ChangeValue 12 0 |
| 172 |
ChangeValue 13 0 |
| 173 |
# hide the sliders |
| 174 |
HideWidget 1 |
| 175 |
HideWidget 2 |
| 176 |
HideWidget 3 |
| 177 |
HideWidget 21 |
| 178 |
HideWidget 22 |
| 179 |
HideWidget 23 |
| 180 |
# change current colorset to be just plain |
| 181 |
If $OldCset == $Cset Then |
| 182 |
Begin |
| 183 |
End |
| 184 |
Else |
| 185 |
Begin |
| 186 |
# I think there might be a bug in Colorset that resets a colorset to a copy of 0 |
| 187 |
# if {pixmap} is used to select a plain background |
| 188 |
Set $Color = (GetBack 1) |
| 189 |
Do {Colorset } $Cset { Pixmap, Background #} $Color {, Foreground Contrast} |
| 190 |
Set $OldCset = $Cset |
| 191 |
End |
| 192 |
End |
| 193 |
End |
| 194 |
|
| 195 |
# Example |
| 196 |
Widget 5 |
| 197 |
Property |
| 198 |
Size 80 34 |
| 199 |
Position 29 10 |
| 200 |
Type ItemDraw |
| 201 |
Title {Colorset 0} |
| 202 |
End |
| 203 |
|
| 204 |
# auto apply selector |
| 205 |
# handles signals from color selectors and passes them on to the apply |
| 206 |
# button if enabled |
| 207 |
Widget 6 |
| 208 |
Property |
| 209 |
Position 120 250 |
| 210 |
Type CheckBox |
| 211 |
Title {Auto Apply} |
| 212 |
Main |
| 213 |
Case message of |
| 214 |
1 : |
| 215 |
Begin |
| 216 |
If (GetValue 6) == 1 Then |
| 217 |
SendSignal 7 1 |
| 218 |
End |
| 219 |
End |
| 220 |
|
| 221 |
# apply button (does the main processing) |
| 222 |
# sends a signal to itself when clicked |
| 223 |
# sets the colorset when it receives a signal |
| 224 |
Widget 7 |
| 225 |
Property |
| 226 |
Position 10 250 |
| 227 |
Type PushButton |
| 228 |
Title {Apply} |
| 229 |
Main |
| 230 |
Case message of |
| 231 |
SingleClic : |
| 232 |
Begin |
| 233 |
SendSignal 7 1 |
| 234 |
End |
| 235 |
1 : |
| 236 |
Begin |
| 237 |
# calculate the current color in RGB hex terms |
| 238 |
Set $Color = {rgb:} (NumToHex (GetValue 1) 2) |
| 239 |
Set $Color = $Color {/} (NumToHex (GetValue 2) 2) |
| 240 |
Set $Color = $Color {/} (NumToHex (GetValue 3) 2) |
| 241 |
# pick the current colorset |
| 242 |
Set $Command = {Colorset } $Cset |
| 243 |
# pick the type to set |
| 244 |
If (GetValue 10) == 1 Then |
| 245 |
Set $Command = $Command { Foreground } $Color |
| 246 |
If (GetValue 11) == 1 Then |
| 247 |
Set $Command = $Command { Hilite } $Color |
| 248 |
If (GetValue 12) == 1 Then |
| 249 |
Set $Command = $Command { Shadow } $Color |
| 250 |
If (GetValue 13) == 1 Then |
| 251 |
Set $Command = $Command { Background } $Color {, Foreground Contrast} |
| 252 |
Do $Command |
| 253 |
End |
| 254 |
End |
| 255 |
|
| 256 |
# RGB sliders |
| 257 |
Widget 1 |
| 258 |
Property |
| 259 |
Size 320 0 |
| 260 |
Position 50 60 |
| 261 |
Type HScrollBar |
| 262 |
MinValue 0 |
| 263 |
MaxValue 255 |
| 264 |
Main |
| 265 |
Case message of |
| 266 |
SingleClic : |
| 267 |
Begin |
| 268 |
SendSignal 6 1 |
| 269 |
End |
| 270 |
End |
| 271 |
|
| 272 |
Widget 21 |
| 273 |
Property |
| 274 |
Size 10 0 |
| 275 |
Position 10 80 |
| 276 |
Type ItemDraw |
| 277 |
Title {Red} |
| 278 |
End |
| 279 |
|
| 280 |
Widget 2 |
| 281 |
Property |
| 282 |
Size 320 0 |
| 283 |
Position 50 120 |
| 284 |
Type HScrollBar |
| 285 |
MinValue 0 |
| 286 |
MaxValue 255 |
| 287 |
Main |
| 288 |
Case message of |
| 289 |
SingleClic : |
| 290 |
Begin |
| 291 |
SendSignal 6 1 |
| 292 |
End |
| 293 |
End |
| 294 |
|
| 295 |
Widget 22 |
| 296 |
Property |
| 297 |
Size 10 0 |
| 298 |
Position 10 140 |
| 299 |
Type ItemDraw |
| 300 |
Title {Green} |
| 301 |
End |
| 302 |
|
| 303 |
Widget 3 |
| 304 |
Property |
| 305 |
Size 320 0 |
| 306 |
Position 50 180 |
| 307 |
Type HScrollBar |
| 308 |
MinValue 0 |
| 309 |
MaxValue 255 |
| 310 |
Main |
| 311 |
Case message of |
| 312 |
SingleClic : |
| 313 |
Begin |
| 314 |
SendSignal 6 1 |
| 315 |
End |
| 316 |
End |
| 317 |
|
| 318 |
Widget 23 |
| 319 |
Property |
| 320 |
Size 10 0 |
| 321 |
Position 10 200 |
| 322 |
Type ItemDraw |
| 323 |
Title {Blue} |
| 324 |
End |