arcadia 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +126 -123
- data/arcadia.rb +770 -756
- data/base/a-contracts.rb +130 -93
- data/base/a-ext.rb +280 -280
- data/base/a-libs.rb +5 -11
- data/base/a-utils.rb +235 -44
- data/conf/arcadia.conf +20 -16
- data/conf/arcadia.init.rb +0 -0
- data/conf/arcadia.res.rb +74 -0
- data/ext/ae-complete-code/ae-complete-code.conf +0 -0
- data/ext/ae-complete-code/ae-complete-code.rb +80 -79
- data/ext/ae-debug/ae-debug.conf +0 -0
- data/ext/ae-debug/ae-debug.rb +2 -6
- data/ext/ae-debug/debug1.57.rb +0 -0
- data/ext/ae-doc-code/ae-doc-code.conf +15 -0
- data/ext/ae-doc-code/ae-doc-code.rb +289 -0
- data/ext/ae-editor/ae-editor.conf +17 -8
- data/ext/ae-editor/ae-editor.rb +738 -396
- data/ext/ae-event-log/ae-event-log.conf +0 -0
- data/ext/ae-event-log/ae-event-log.rb +0 -0
- data/ext/ae-file-history/ae-file-history.conf +2 -2
- data/ext/ae-file-history/ae-file-history.rb +286 -290
- data/ext/ae-inspector/ae-inspector.conf +0 -0
- data/ext/ae-inspector/ae-inspector.rb +0 -0
- data/ext/ae-output-event/ae-output-event.conf +2 -2
- data/ext/ae-output/ae-output.conf +2 -2
- data/ext/ae-output/ae-output.rb +173 -178
- data/ext/ae-palette/ae-palette.conf +0 -0
- data/ext/ae-palette/ae-palette.rb +0 -0
- data/ext/ae-shell/ae-shell.conf +0 -0
- data/ext/ae-shell/ae-shell.rb +54 -54
- data/lib/tk/al-tk.rb +3076 -3082
- data/lib/tk/al-tk.res.rb +0 -0
- data/lib/tk/al-tkarcadia.rb +0 -0
- data/lib/tk/al-tkcustom.rb +0 -0
- data/lib/tkext/al-bwidget.rb +0 -0
- data/lib/tkext/al-iwidgets.rb +0 -0
- data/lib/tkext/al-tile.rb +0 -0
- data/lib/tkext/al-tktable.rb +0 -0
- data/tcl/BWidget-1.8.0/BWman/ArrowButton.html +276 -0
- data/tcl/BWidget-1.8.0/BWman/BWidget.html +228 -0
- data/tcl/BWidget-1.8.0/BWman/Button.html +273 -0
- data/tcl/BWidget-1.8.0/BWman/ButtonBox.html +264 -0
- data/tcl/BWidget-1.8.0/BWman/ComboBox.html +402 -0
- data/tcl/BWidget-1.8.0/BWman/Dialog.html +314 -0
- data/tcl/BWidget-1.8.0/BWman/DragSite.html +139 -0
- data/tcl/BWidget-1.8.0/BWman/DropSite.html +254 -0
- data/tcl/BWidget-1.8.0/BWman/DynamicHelp.html +248 -0
- data/tcl/BWidget-1.8.0/BWman/Entry.html +341 -0
- data/tcl/BWidget-1.8.0/BWman/Label.html +331 -0
- data/tcl/BWidget-1.8.0/BWman/LabelEntry.html +194 -0
- data/tcl/BWidget-1.8.0/BWman/LabelFrame.html +144 -0
- data/tcl/BWidget-1.8.0/BWman/ListBox.html +678 -0
- data/tcl/BWidget-1.8.0/BWman/MainFrame.html +283 -0
- data/tcl/BWidget-1.8.0/BWman/MessageDlg.html +218 -0
- data/tcl/BWidget-1.8.0/BWman/NoteBook.html +374 -0
- data/tcl/BWidget-1.8.0/BWman/PagesManager.html +180 -0
- data/tcl/BWidget-1.8.0/BWman/PanedWindow.html +142 -0
- data/tcl/BWidget-1.8.0/BWman/PanelFrame.html +153 -0
- data/tcl/BWidget-1.8.0/BWman/PasswdDlg.html +214 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressBar.html +152 -0
- data/tcl/BWidget-1.8.0/BWman/ProgressDlg.html +145 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollView.html +130 -0
- data/tcl/BWidget-1.8.0/BWman/ScrollableFrame.html +191 -0
- data/tcl/BWidget-1.8.0/BWman/ScrolledWindow.html +116 -0
- data/tcl/BWidget-1.8.0/BWman/SelectColor.html +164 -0
- data/tcl/BWidget-1.8.0/BWman/SelectFont.html +152 -0
- data/tcl/BWidget-1.8.0/BWman/Separator.html +77 -0
- data/tcl/BWidget-1.8.0/BWman/SpinBox.html +250 -0
- data/tcl/BWidget-1.8.0/BWman/StatusBar.html +147 -0
- data/tcl/BWidget-1.8.0/BWman/TitleFrame.html +107 -0
- data/tcl/BWidget-1.8.0/BWman/Tree.html +947 -0
- data/tcl/BWidget-1.8.0/BWman/Widget.html +502 -0
- data/tcl/BWidget-1.8.0/BWman/contents.html +84 -0
- data/tcl/BWidget-1.8.0/BWman/index.html +7 -0
- data/tcl/BWidget-1.8.0/BWman/navtree.html +41 -0
- data/tcl/BWidget-1.8.0/BWman/options.htm +458 -0
- data/tcl/BWidget-1.8.0/CHANGES.txt +266 -0
- data/tcl/BWidget-1.8.0/ChangeLog +1641 -0
- data/tcl/BWidget-1.8.0/LICENSE.txt +41 -0
- data/tcl/BWidget-1.8.0/README.txt +127 -0
- data/tcl/BWidget-1.8.0/arrow.tcl +551 -0
- data/tcl/BWidget-1.8.0/bitmap.tcl +94 -0
- data/tcl/BWidget-1.8.0/button.tcl +324 -0
- data/tcl/BWidget-1.8.0/buttonbox.tcl +403 -0
- data/tcl/BWidget-1.8.0/color.tcl +493 -0
- data/tcl/BWidget-1.8.0/combobox.tcl +809 -0
- data/tcl/BWidget-1.8.0/demo/basic.tcl +199 -0
- data/tcl/BWidget-1.8.0/demo/bwidget.xbm +46 -0
- data/tcl/BWidget-1.8.0/demo/demo.tcl +212 -0
- data/tcl/BWidget-1.8.0/demo/dnd.tcl +42 -0
- data/tcl/BWidget-1.8.0/demo/manager.tcl +141 -0
- data/tcl/BWidget-1.8.0/demo/select.tcl +59 -0
- data/tcl/BWidget-1.8.0/demo/tmpldlg.tcl +214 -0
- data/tcl/BWidget-1.8.0/demo/tree.tcl +260 -0
- data/tcl/BWidget-1.8.0/demo/x1.xbm +2258 -0
- data/tcl/BWidget-1.8.0/dialog.tcl +345 -0
- data/tcl/BWidget-1.8.0/dragsite.tcl +197 -0
- data/tcl/BWidget-1.8.0/dropsite.tcl +455 -0
- data/tcl/BWidget-1.8.0/dynhelp.tcl +625 -0
- data/tcl/BWidget-1.8.0/entry.tcl +469 -0
- data/tcl/BWidget-1.8.0/font.tcl +566 -0
- data/tcl/BWidget-1.8.0/images/bold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/copy.gif +0 -0
- data/tcl/BWidget-1.8.0/images/cut.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragfile.gif +0 -0
- data/tcl/BWidget-1.8.0/images/dragicon.gif +0 -0
- data/tcl/BWidget-1.8.0/images/error.gif +0 -0
- data/tcl/BWidget-1.8.0/images/file.gif +0 -0
- data/tcl/BWidget-1.8.0/images/folder.gif +0 -0
- data/tcl/BWidget-1.8.0/images/hourglass.gif +0 -0
- data/tcl/BWidget-1.8.0/images/info.gif +0 -0
- data/tcl/BWidget-1.8.0/images/italic.gif +0 -0
- data/tcl/BWidget-1.8.0/images/minus.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/new.gif +0 -0
- data/tcl/BWidget-1.8.0/images/opcopy.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/open.gif +0 -0
- data/tcl/BWidget-1.8.0/images/openfold.gif +0 -0
- data/tcl/BWidget-1.8.0/images/oplink.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/opmove.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/overstrike.gif +0 -0
- data/tcl/BWidget-1.8.0/images/palette.gif +0 -0
- data/tcl/BWidget-1.8.0/images/passwd.gif +0 -0
- data/tcl/BWidget-1.8.0/images/paste.gif +0 -0
- data/tcl/BWidget-1.8.0/images/plus.xbm +5 -0
- data/tcl/BWidget-1.8.0/images/print.gif +0 -0
- data/tcl/BWidget-1.8.0/images/question.gif +0 -0
- data/tcl/BWidget-1.8.0/images/redo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/save.gif +0 -0
- data/tcl/BWidget-1.8.0/images/target.xbm +9 -0
- data/tcl/BWidget-1.8.0/images/underline.gif +0 -0
- data/tcl/BWidget-1.8.0/images/undo.gif +0 -0
- data/tcl/BWidget-1.8.0/images/warning.gif +0 -0
- data/tcl/BWidget-1.8.0/init.tcl +40 -0
- data/tcl/BWidget-1.8.0/label.tcl +271 -0
- data/tcl/BWidget-1.8.0/labelentry.tcl +100 -0
- data/tcl/BWidget-1.8.0/labelframe.tcl +160 -0
- data/tcl/BWidget-1.8.0/lang/da.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/de.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/en.rc +52 -0
- data/tcl/BWidget-1.8.0/lang/es.rc +53 -0
- data/tcl/BWidget-1.8.0/lang/fr.rc +52 -0
- data/tcl/BWidget-1.8.0/listbox.tcl +1638 -0
- data/tcl/BWidget-1.8.0/mainframe.tcl +711 -0
- data/tcl/BWidget-1.8.0/messagedlg.tcl +128 -0
- data/tcl/BWidget-1.8.0/notebook.tcl +1164 -0
- data/tcl/BWidget-1.8.0/pagesmgr.tcl +294 -0
- data/tcl/BWidget-1.8.0/panedw.tcl +381 -0
- data/tcl/BWidget-1.8.0/panelframe.tcl +246 -0
- data/tcl/BWidget-1.8.0/passwddlg.tcl +178 -0
- data/tcl/BWidget-1.8.0/pkgIndex.tcl +47 -0
- data/tcl/BWidget-1.8.0/progressbar.tcl +208 -0
- data/tcl/BWidget-1.8.0/progressdlg.tcl +87 -0
- data/tcl/BWidget-1.8.0/scrollframe.tcl +226 -0
- data/tcl/BWidget-1.8.0/scrollview.tcl +254 -0
- data/tcl/BWidget-1.8.0/scrollw.tcl +280 -0
- data/tcl/BWidget-1.8.0/separator.tcl +75 -0
- data/tcl/BWidget-1.8.0/spinbox.tcl +331 -0
- data/tcl/BWidget-1.8.0/statusbar.tcl +422 -0
- data/tcl/BWidget-1.8.0/tests/entry.test +173 -0
- data/tcl/BWidget-1.8.0/titleframe.tcl +170 -0
- data/tcl/BWidget-1.8.0/tree.tcl +2228 -0
- data/tcl/BWidget-1.8.0/utils.tcl +645 -0
- data/tcl/BWidget-1.8.0/widget.tcl +1576 -0
- data/tcl/BWidget-1.8.0/wizard.tcl +1028 -0
- data/tcl/BWidget-1.8.0/xpm2image.tcl +115 -0
- metadata +141 -5
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
namespace eval SelectColor {
|
|
2
|
+
Widget::define SelectColor color Dialog
|
|
3
|
+
|
|
4
|
+
Widget::declare SelectColor {
|
|
5
|
+
{-title String "Select a color" 0}
|
|
6
|
+
{-parent String "" 0}
|
|
7
|
+
{-color TkResource "" 0 {label -background}}
|
|
8
|
+
{-type Enum "dialog" 1 {dialog popup}}
|
|
9
|
+
{-placement String "center" 1}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
variable _baseColors {
|
|
13
|
+
\#0000ff \#00ff00 \#00ffff \#ff0000 \#ff00ff \#ffff00
|
|
14
|
+
\#000099 \#009900 \#009999 \#990000 \#990099 \#999900
|
|
15
|
+
\#000000 \#333333 \#666666 \#999999 \#cccccc \#ffffff
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
variable _userColors {
|
|
19
|
+
\#ffffff \#ffffff \#ffffff \#ffffff \#ffffff \#ffffff
|
|
20
|
+
\#ffffff \#ffffff \#ffffff \#ffffff \#ffffff
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if {[string equal $::tcl_platform(platform) "unix"]} {
|
|
24
|
+
set useTkDialogue 0
|
|
25
|
+
} else {
|
|
26
|
+
set useTkDialogue 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
variable _selectype
|
|
30
|
+
variable _selection
|
|
31
|
+
variable _wcolor
|
|
32
|
+
variable _image
|
|
33
|
+
variable _hsv
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
proc SelectColor::create { path args } {
|
|
37
|
+
Widget::init SelectColor $path $args
|
|
38
|
+
|
|
39
|
+
set type [Widget::cget $path -type]
|
|
40
|
+
|
|
41
|
+
switch -- [Widget::cget $path -type] {
|
|
42
|
+
"dialog" {
|
|
43
|
+
return [eval [list SelectColor::dialog $path] $args]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
"popup" {
|
|
47
|
+
set list [list at center left right above below]
|
|
48
|
+
set placement [Widget::cget $path -placement]
|
|
49
|
+
set where [lindex $placement 0]
|
|
50
|
+
|
|
51
|
+
if {[lsearch $list $where] < 0} {
|
|
52
|
+
return -code error \
|
|
53
|
+
[BWidget::badOptionString placement $placement $list]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
## If they specified a parent and didn't pass a second argument
|
|
57
|
+
## in the placement, set the placement relative to the parent.
|
|
58
|
+
set parent [Widget::cget $path -parent]
|
|
59
|
+
if {[string length $parent]} {
|
|
60
|
+
if {[llength $placement] == 1} { lappend placement $parent }
|
|
61
|
+
}
|
|
62
|
+
return [eval [list SelectColor::menu $path $placement] $args]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
proc SelectColor::menu {path placement args} {
|
|
68
|
+
variable _baseColors
|
|
69
|
+
variable _userColors
|
|
70
|
+
variable _wcolor
|
|
71
|
+
variable _selectype
|
|
72
|
+
variable _selection
|
|
73
|
+
|
|
74
|
+
Widget::init SelectColor $path $args
|
|
75
|
+
set top [toplevel $path]
|
|
76
|
+
set parent [winfo toplevel [winfo parent $top]]
|
|
77
|
+
wm withdraw $top
|
|
78
|
+
wm transient $top $parent
|
|
79
|
+
wm overrideredirect $top 1
|
|
80
|
+
catch { wm attributes $top -topmost 1 }
|
|
81
|
+
|
|
82
|
+
set frame [frame $top.frame \
|
|
83
|
+
-highlightthickness 0 \
|
|
84
|
+
-relief raised -borderwidth 2]
|
|
85
|
+
set col 0
|
|
86
|
+
set row 0
|
|
87
|
+
set count 0
|
|
88
|
+
set colors [concat $_baseColors $_userColors]
|
|
89
|
+
foreach color $colors {
|
|
90
|
+
set f [frame $frame.c$count \
|
|
91
|
+
-highlightthickness 2 \
|
|
92
|
+
-highlightcolor white \
|
|
93
|
+
-relief solid -borderwidth 1 \
|
|
94
|
+
-width 16 -height 16 -background $color]
|
|
95
|
+
bind $f <1> "set SelectColor::_selection $count; break"
|
|
96
|
+
bind $f <Enter> {focus %W}
|
|
97
|
+
grid $f -column $col -row $row
|
|
98
|
+
incr count
|
|
99
|
+
if {[incr col] == 6 } {
|
|
100
|
+
set col 0
|
|
101
|
+
incr row
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
set f [label $frame.c$count \
|
|
105
|
+
-highlightthickness 2 \
|
|
106
|
+
-highlightcolor white \
|
|
107
|
+
-relief flat -borderwidth 0 \
|
|
108
|
+
-width 16 -height 16 -image [Bitmap::get palette]]
|
|
109
|
+
grid $f -column $col -row $row
|
|
110
|
+
bind $f <1> "set SelectColor::_selection $count; break"
|
|
111
|
+
bind $f <Enter> {focus %W}
|
|
112
|
+
pack $frame
|
|
113
|
+
|
|
114
|
+
bind $top <1> {set SelectColor::_selection -1}
|
|
115
|
+
bind $top <Escape> {set SelectColor::_selection -2}
|
|
116
|
+
bind $top <FocusOut> [subst {if {"%W" == "$top"} \
|
|
117
|
+
{set SelectColor::_selection -2}}]
|
|
118
|
+
eval [list BWidget::place $top 0 0] $placement
|
|
119
|
+
|
|
120
|
+
wm deiconify $top
|
|
121
|
+
raise $top
|
|
122
|
+
if {$::tcl_platform(platform) == "unix"} {
|
|
123
|
+
tkwait visibility $top
|
|
124
|
+
update
|
|
125
|
+
}
|
|
126
|
+
BWidget::SetFocusGrab $top $frame.c0
|
|
127
|
+
|
|
128
|
+
vwait SelectColor::_selection
|
|
129
|
+
BWidget::RestoreFocusGrab $top $frame.c0 destroy
|
|
130
|
+
Widget::destroy $top
|
|
131
|
+
if {$_selection == $count} {
|
|
132
|
+
array set opts {
|
|
133
|
+
-parent -parent
|
|
134
|
+
-title -title
|
|
135
|
+
-color -initialcolor
|
|
136
|
+
}
|
|
137
|
+
if {[Widget::theme]} {
|
|
138
|
+
set native 1
|
|
139
|
+
set nativecmd [list tk_chooseColor -parent $parent]
|
|
140
|
+
foreach {key val} $args {
|
|
141
|
+
if {![info exists opts($key)]} {
|
|
142
|
+
set native 0
|
|
143
|
+
break
|
|
144
|
+
}
|
|
145
|
+
lappend nativecmd $opts($key) $val
|
|
146
|
+
}
|
|
147
|
+
if {$native} {
|
|
148
|
+
return [eval $nativecmd]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [eval [list dialog $path] $args]
|
|
152
|
+
} else {
|
|
153
|
+
return [lindex $colors $_selection]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
proc SelectColor::dialog {path args} {
|
|
159
|
+
variable _baseColors
|
|
160
|
+
variable _userColors
|
|
161
|
+
variable _widget
|
|
162
|
+
variable _selection
|
|
163
|
+
variable _image
|
|
164
|
+
variable _hsv
|
|
165
|
+
|
|
166
|
+
Widget::init SelectColor $path:SelectColor $args
|
|
167
|
+
set top [Dialog::create $path \
|
|
168
|
+
-title [Widget::cget $path:SelectColor -title] \
|
|
169
|
+
-parent [Widget::cget $path:SelectColor -parent] \
|
|
170
|
+
-separator 1 -default 0 -cancel 1 -anchor e]
|
|
171
|
+
wm resizable $top 0 0
|
|
172
|
+
set dlgf [$top getframe]
|
|
173
|
+
set fg [frame $dlgf.fg]
|
|
174
|
+
set desc [list \
|
|
175
|
+
base _baseColors "Base colors" \
|
|
176
|
+
user _userColors "User colors"]
|
|
177
|
+
set count 0
|
|
178
|
+
foreach {type varcol defTitle} $desc {
|
|
179
|
+
set col 0
|
|
180
|
+
set lin 0
|
|
181
|
+
set title [lindex [BWidget::getname "${type}Colors"] 0]
|
|
182
|
+
if {![string length $title]} {
|
|
183
|
+
set title $defTitle
|
|
184
|
+
}
|
|
185
|
+
set titf [TitleFrame $fg.$type -text $title]
|
|
186
|
+
set subf [$titf getframe]
|
|
187
|
+
foreach color [set $varcol] {
|
|
188
|
+
set fround [frame $fg.round$count \
|
|
189
|
+
-highlightthickness 1 \
|
|
190
|
+
-relief sunken -borderwidth 2]
|
|
191
|
+
set fcolor [frame $fg.color$count -width 16 -height 12 \
|
|
192
|
+
-highlightthickness 0 \
|
|
193
|
+
-relief flat -borderwidth 0 \
|
|
194
|
+
-background $color]
|
|
195
|
+
pack $fcolor -in $fround
|
|
196
|
+
grid $fround -in $subf -row $lin -column $col -padx 1 -pady 1
|
|
197
|
+
|
|
198
|
+
bind $fround <ButtonPress-1> [list SelectColor::_select_rgb $count]
|
|
199
|
+
bind $fcolor <ButtonPress-1> [list SelectColor::_select_rgb $count]
|
|
200
|
+
|
|
201
|
+
bind $fround <Double-1> \
|
|
202
|
+
"SelectColor::_select_rgb [list $count]; [list $top] invoke 0"
|
|
203
|
+
bind $fcolor <Double-1> \
|
|
204
|
+
"SelectColor::_select_rgb [list $count]; [list $top] invoke 0"
|
|
205
|
+
|
|
206
|
+
incr count
|
|
207
|
+
if {[incr col] == 6} {
|
|
208
|
+
incr lin
|
|
209
|
+
set col 0
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
pack $titf -anchor w -pady 2
|
|
213
|
+
}
|
|
214
|
+
set fround [frame $fg.round \
|
|
215
|
+
-highlightthickness 0 \
|
|
216
|
+
-relief sunken -borderwidth 2]
|
|
217
|
+
set fcolor [frame $fg.color \
|
|
218
|
+
-width 50 \
|
|
219
|
+
-highlightthickness 0 \
|
|
220
|
+
-relief flat -borderwidth 0]
|
|
221
|
+
pack $fcolor -in $fround -fill y -expand yes
|
|
222
|
+
pack $fround -anchor e -pady 2 -fill y -expand yes
|
|
223
|
+
|
|
224
|
+
set fd [frame $dlgf.fd]
|
|
225
|
+
set f1 [frame $fd.f1 -relief sunken -borderwidth 2]
|
|
226
|
+
set f2 [frame $fd.f2 -relief sunken -borderwidth 2]
|
|
227
|
+
set c1 [canvas $f1.c -width 200 -height 200 -bd 0 -highlightthickness 0]
|
|
228
|
+
set c2 [canvas $f2.c -width 15 -height 200 -bd 0 -highlightthickness 0]
|
|
229
|
+
|
|
230
|
+
for {set val 0} {$val < 40} {incr val} {
|
|
231
|
+
$c2 create rectangle 0 [expr {5*$val}] 15 [expr {5*$val+5}] -tags val[expr {39-$val}]
|
|
232
|
+
}
|
|
233
|
+
$c2 create polygon 0 0 10 5 0 10 -fill black -outline white -tags target
|
|
234
|
+
|
|
235
|
+
pack $c1 $c2
|
|
236
|
+
pack $f1 $f2 -side left -padx 10 -anchor n
|
|
237
|
+
|
|
238
|
+
pack $fg $fd -side left -anchor n -fill y
|
|
239
|
+
|
|
240
|
+
bind $c1 <ButtonPress-1> [list SelectColor::_select_hue_sat %x %y]
|
|
241
|
+
bind $c1 <B1-Motion> [list SelectColor::_select_hue_sat %x %y]
|
|
242
|
+
|
|
243
|
+
bind $c2 <ButtonPress-1> [list SelectColor::_select_value %x %y]
|
|
244
|
+
bind $c2 <B1-Motion> [list SelectColor::_select_value %x %y]
|
|
245
|
+
|
|
246
|
+
if {![info exists _image] || [catch {image type $_image}]} {
|
|
247
|
+
set _image [image create photo -width 200 -height 200]
|
|
248
|
+
for {set x 0} {$x < 200} {incr x 4} {
|
|
249
|
+
for {set y 0} {$y < 200} {incr y 4} {
|
|
250
|
+
$_image put \
|
|
251
|
+
[eval [list format "\#%04x%04x%04x"] \
|
|
252
|
+
[hsvToRgb [expr {$x/196.0}] [expr {(196-$y)/196.0}] 0.85]] \
|
|
253
|
+
-to $x $y [expr {$x+4}] [expr {$y+4}]
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
$c1 create image 0 0 -anchor nw -image $_image
|
|
258
|
+
$c1 create bitmap 0 0 \
|
|
259
|
+
-bitmap @[file join $::BWIDGET::LIBRARY "images" "target.xbm"] \
|
|
260
|
+
-anchor nw -tags target
|
|
261
|
+
|
|
262
|
+
set _selection -1
|
|
263
|
+
set _widget(fcolor) $fg
|
|
264
|
+
set _widget(chs) $c1
|
|
265
|
+
set _widget(cv) $c2
|
|
266
|
+
set rgb [winfo rgb $path [Widget::cget $path:SelectColor -color]]
|
|
267
|
+
set _hsv [eval rgbToHsv $rgb]
|
|
268
|
+
_set_rgb [eval [list format "\#%04x%04x%04x"] $rgb]
|
|
269
|
+
_set_hue_sat [lindex $_hsv 0] [lindex $_hsv 1]
|
|
270
|
+
_set_value [lindex $_hsv 2]
|
|
271
|
+
|
|
272
|
+
$top add -name ok
|
|
273
|
+
$top add -name cancel
|
|
274
|
+
set res [$top draw]
|
|
275
|
+
if {$res == 0} {
|
|
276
|
+
set color [$fg.color cget -background]
|
|
277
|
+
} else {
|
|
278
|
+
set color ""
|
|
279
|
+
}
|
|
280
|
+
destroy $top
|
|
281
|
+
return $color
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
proc SelectColor::setcolor { idx color } {
|
|
285
|
+
variable _userColors
|
|
286
|
+
set _userColors [lreplace $_userColors $idx $idx $color]
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
proc SelectColor::_select_rgb {count} {
|
|
290
|
+
variable _baseColors
|
|
291
|
+
variable _userColors
|
|
292
|
+
variable _selection
|
|
293
|
+
variable _widget
|
|
294
|
+
variable _hsv
|
|
295
|
+
|
|
296
|
+
set frame $_widget(fcolor)
|
|
297
|
+
if {$_selection >= 0} {
|
|
298
|
+
$frame.round$_selection configure \
|
|
299
|
+
-relief sunken -highlightthickness 1 -borderwidth 2
|
|
300
|
+
}
|
|
301
|
+
$frame.round$count configure \
|
|
302
|
+
-relief flat -highlightthickness 2 -borderwidth 1
|
|
303
|
+
focus $frame.round$count
|
|
304
|
+
set _selection $count
|
|
305
|
+
set bg [$frame.color$count cget -background]
|
|
306
|
+
set user [expr {$_selection-[llength $_baseColors]}]
|
|
307
|
+
if {$user >= 0 &&
|
|
308
|
+
[string equal \
|
|
309
|
+
[winfo rgb $frame.color$_selection $bg] \
|
|
310
|
+
[winfo rgb $frame.color$_selection white]]} {
|
|
311
|
+
set bg [$frame.color cget -bg]
|
|
312
|
+
$frame.color$_selection configure -background $bg
|
|
313
|
+
set _userColors [lreplace $_userColors $user $user $bg]
|
|
314
|
+
} else {
|
|
315
|
+
set _hsv [eval rgbToHsv [winfo rgb $frame.color$count $bg]]
|
|
316
|
+
_set_hue_sat [lindex $_hsv 0] [lindex $_hsv 1]
|
|
317
|
+
_set_value [lindex $_hsv 2]
|
|
318
|
+
$frame.color configure -background $bg
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
proc SelectColor::_set_rgb {rgb} {
|
|
324
|
+
variable _selection
|
|
325
|
+
variable _baseColors
|
|
326
|
+
variable _userColors
|
|
327
|
+
variable _widget
|
|
328
|
+
|
|
329
|
+
set frame $_widget(fcolor)
|
|
330
|
+
$frame.color configure -background $rgb
|
|
331
|
+
set user [expr {$_selection-[llength $_baseColors]}]
|
|
332
|
+
if {$user >= 0} {
|
|
333
|
+
$frame.color$_selection configure -background $rgb
|
|
334
|
+
set _userColors [lreplace $_userColors $user $user $rgb]
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
proc SelectColor::_select_hue_sat {x y} {
|
|
340
|
+
variable _widget
|
|
341
|
+
variable _hsv
|
|
342
|
+
|
|
343
|
+
if {$x < 0} {
|
|
344
|
+
set x 0
|
|
345
|
+
} elseif {$x > 200} {
|
|
346
|
+
set x 200
|
|
347
|
+
}
|
|
348
|
+
if {$y < 0 } {
|
|
349
|
+
set y 0
|
|
350
|
+
} elseif {$y > 200} {
|
|
351
|
+
set y 200
|
|
352
|
+
}
|
|
353
|
+
set hue [expr {$x/200.0}]
|
|
354
|
+
set sat [expr {(200-$y)/200.0}]
|
|
355
|
+
set _hsv [lreplace $_hsv 0 1 $hue $sat]
|
|
356
|
+
$_widget(chs) coords target [expr {$x-9}] [expr {$y-9}]
|
|
357
|
+
_draw_values $hue $sat
|
|
358
|
+
_set_rgb [eval [list format "\#%04x%04x%04x"] [eval [list hsvToRgb] $_hsv]]
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
proc SelectColor::_set_hue_sat {hue sat} {
|
|
363
|
+
variable _widget
|
|
364
|
+
|
|
365
|
+
set x [expr {$hue*200-9}]
|
|
366
|
+
set y [expr {(1-$sat)*200-9}]
|
|
367
|
+
$_widget(chs) coords target $x $y
|
|
368
|
+
_draw_values $hue $sat
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
proc SelectColor::_select_value {x y} {
|
|
374
|
+
variable _widget
|
|
375
|
+
variable _hsv
|
|
376
|
+
|
|
377
|
+
if {$y < 0} {
|
|
378
|
+
set y 0
|
|
379
|
+
} elseif {$y > 200} {
|
|
380
|
+
set y 200
|
|
381
|
+
}
|
|
382
|
+
$_widget(cv) coords target 0 [expr {$y-5}] 10 $y 0 [expr {$y+5}]
|
|
383
|
+
set _hsv [lreplace $_hsv 2 2 [expr {(200-$y)/200.0}]]
|
|
384
|
+
_set_rgb [eval [list format "\#%04x%04x%04x"] [eval [list hsvToRgb] $_hsv]]
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
proc SelectColor::_draw_values {hue sat} {
|
|
389
|
+
variable _widget
|
|
390
|
+
|
|
391
|
+
for {set val 0} {$val < 40} {incr val} {
|
|
392
|
+
set l [hsvToRgb $hue $sat [expr {$val/39.0}]]
|
|
393
|
+
set col [eval [list format "\#%04x%04x%04x"] $l]
|
|
394
|
+
$_widget(cv) itemconfigure val$val -fill $col -outline $col
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
proc SelectColor::_set_value {value} {
|
|
400
|
+
variable _widget
|
|
401
|
+
|
|
402
|
+
set y [expr {int((1-$value)*200)}]
|
|
403
|
+
$_widget(cv) coords target 0 [expr {$y-5}] 10 $y 0 [expr {$y+5}]
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
# --
|
|
408
|
+
# Taken from tk8.0/demos/tcolor.tcl
|
|
409
|
+
# --
|
|
410
|
+
# The procedure below converts an HSB value to RGB. It takes hue, saturation,
|
|
411
|
+
# and value components (floating-point, 0-1.0) as arguments, and returns a
|
|
412
|
+
# list containing RGB components (integers, 0-65535) as result. The code
|
|
413
|
+
# here is a copy of the code on page 616 of "Fundamentals of Interactive
|
|
414
|
+
# Computer Graphics" by Foley and Van Dam.
|
|
415
|
+
|
|
416
|
+
proc SelectColor::hsvToRgb {hue sat val} {
|
|
417
|
+
set v [expr {round(65535.0*$val)}]
|
|
418
|
+
if {$sat == 0} {
|
|
419
|
+
return [list $v $v $v]
|
|
420
|
+
} else {
|
|
421
|
+
set hue [expr {$hue*6.0}]
|
|
422
|
+
if {$hue >= 6.0} {
|
|
423
|
+
set hue 0.0
|
|
424
|
+
}
|
|
425
|
+
set i [expr {int($hue)}]
|
|
426
|
+
set f [expr {$hue-$i}]
|
|
427
|
+
set p [expr {round(65535.0*$val*(1 - $sat))}]
|
|
428
|
+
set q [expr {round(65535.0*$val*(1 - ($sat*$f)))}]
|
|
429
|
+
set t [expr {round(65535.0*$val*(1 - ($sat*(1 - $f))))}]
|
|
430
|
+
switch $i {
|
|
431
|
+
0 {return [list $v $t $p]}
|
|
432
|
+
1 {return [list $q $v $p]}
|
|
433
|
+
2 {return [list $p $v $t]}
|
|
434
|
+
3 {return [list $p $q $v]}
|
|
435
|
+
4 {return [list $t $p $v]}
|
|
436
|
+
5 {return [list $v $p $q]}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
# --
|
|
443
|
+
# Taken from tk8.0/demos/tcolor.tcl
|
|
444
|
+
# --
|
|
445
|
+
# The procedure below converts an RGB value to HSB. It takes red, green,
|
|
446
|
+
# and blue components (0-65535) as arguments, and returns a list containing
|
|
447
|
+
# HSB components (floating-point, 0-1) as result. The code here is a copy
|
|
448
|
+
# of the code on page 615 of "Fundamentals of Interactive Computer Graphics"
|
|
449
|
+
# by Foley and Van Dam.
|
|
450
|
+
|
|
451
|
+
proc SelectColor::rgbToHsv {red green blue} {
|
|
452
|
+
if {$red > $green} {
|
|
453
|
+
set max $red.0
|
|
454
|
+
set min $green.0
|
|
455
|
+
} else {
|
|
456
|
+
set max $green.0
|
|
457
|
+
set min $red.0
|
|
458
|
+
}
|
|
459
|
+
if {$blue > $max} {
|
|
460
|
+
set max $blue.0
|
|
461
|
+
} else {
|
|
462
|
+
if {$blue < $min} {
|
|
463
|
+
set min $blue.0
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
set range [expr {$max-$min}]
|
|
467
|
+
if {$max == 0} {
|
|
468
|
+
set sat 0
|
|
469
|
+
} else {
|
|
470
|
+
set sat [expr {($max-$min)/$max}]
|
|
471
|
+
}
|
|
472
|
+
if {$sat == 0} {
|
|
473
|
+
set hue 0
|
|
474
|
+
} else {
|
|
475
|
+
set rc [expr {($max - $red)/$range}]
|
|
476
|
+
set gc [expr {($max - $green)/$range}]
|
|
477
|
+
set bc [expr {($max - $blue)/$range}]
|
|
478
|
+
if {$red == $max} {
|
|
479
|
+
set hue [expr {.166667*($bc - $gc)}]
|
|
480
|
+
} else {
|
|
481
|
+
if {$green == $max} {
|
|
482
|
+
set hue [expr {.166667*(2 + $rc - $bc)}]
|
|
483
|
+
} else {
|
|
484
|
+
set hue [expr {.166667*(4 + $gc - $rc)}]
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if {$hue < 0.0} {
|
|
488
|
+
set hue [expr {$hue + 1.0}]
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return [list $hue $sat [expr {$max/65535}]]
|
|
492
|
+
}
|
|
493
|
+
|