• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/tcl-102/tk84/tk/library/

Lines Matching defs:color

4 #	standard color selection dialog.
17 # (2): Implement HSV color selection.
23 namespace eval ::tk::dialog::color {
27 # ::tk::dialog::color:: --
29 # Create a color dialog and let the user choose a color. This function
31 # function when a native color selector widget does not exist
33 proc ::tk::dialog::color:: {args} {
36 upvar ::tk::dialog::color::$dataName data
48 # This is the actual number of lines that are drawn in each color strip.
54 # BARS_WIDTH is the number of pixels wide the color bar portion of the
64 # selection rectangle at the bottom of the color bar. No restrictions.
116 # ::tk::dialog::color::InitValues --
120 proc ::tk::dialog::color::InitValues {dataName} {
121 upvar ::tk::dialog::color::$dataName data
123 # IntensityIncr is the difference in color intensity between a colorbar
154 # Set the initial color, specified by -initialcolor, or the
155 # color chosen by the user the last time.
165 # ::tk::dialog::color::Config --
169 proc ::tk::dialog::color::Config {dataName argList} {
171 upvar ::tk::dialog::color::$dataName data
189 tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList
203 # ::tk::dialog::color::BuildDialog --
207 proc ::tk::dialog::color::BuildDialog {w} {
208 upvar ::tk::dialog::color::[winfo name $w] data
210 # TopFrame contains the color strips and the color selection
224 foreach {color l} $colorList {
225 # each f frame contains an [R|G|B] entry and the equiv. color strip.
226 set f [frame $stripsFrame.$color]
235 ::tk::dialog::color::[winfo name $w]($color,intensity) \
245 canvas $f.color -height $height\
249 pack $f.color -expand yes -fill both
254 set data($color,entry) $box.entry
255 set data($color,col) $f.color
256 set data($color,sel) $f.sel
258 bind $data($color,col) <Configure> \
259 [list tk::dialog::color::DrawColorScale $w $color 1]
260 bind $data($color,col) <Enter> \
261 [list tk::dialog::color::EnterColorBar $w $color]
262 bind $data($color,col) <Leave> \
263 [list tk::dialog::color::LeaveColorBar $w $color]
265 bind $data($color,sel) <Enter> \
266 [list tk::dialog::color::EnterColorBar $w $color]
267 bind $data($color,sel) <Leave> \
268 [list tk::dialog::color::LeaveColorBar $w $color]
270 bind $box.entry <Return> [list tk::dialog::color::HandleRGBEntry $w]
276 # selected color
282 -textvariable ::tk::dialog::color::[winfo name $w](selection) \
291 bind $ent <Return> [list tk::dialog::color::HandleSelEntry $w]
301 -command [list tk::dialog::color::OkCmd $w]
303 -command [list tk::dialog::color::CancelCmd $w]
321 wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w]
324 # ::tk::dialog::color::SetRGBValue --
328 proc ::tk::dialog::color::SetRGBValue {w color} {
329 upvar ::tk::dialog::color::[winfo name $w] data
331 set data(red,intensity) [lindex $color 0]
332 set data(green,intensity) [lindex $color 1]
333 set data(blue,intensity) [lindex $color 2]
338 foreach color [list red green blue ] {
339 set x [RgbToX $w $data($color,intensity)]
340 MoveSelector $w $data($color,sel) $color $x 0
344 # ::tk::dialog::color::XToRgb --
348 proc ::tk::dialog::color::XToRgb {w x} {
349 upvar ::tk::dialog::color::[winfo name $w] data
356 # ::tk::dialog::color::RgbToX
360 proc ::tk::dialog::color::RgbToX {w color} {
361 upvar ::tk::dialog::color::[winfo name $w] data
363 return [expr {($color * $data(colorbarWidth)/ $data(intensityIncr))}]
367 # ::tk::dialog::color::DrawColorScale --
369 # Draw color scale is called whenever the size of one of the color
372 proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
373 upvar ::tk::dialog::color::[winfo name $w] data
375 # col: color bar canvas
397 [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
399 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
401 [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
410 [list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
412 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
414 [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
417 [list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
419 [list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
421 [list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
427 # Draw the color bars.
433 set color [format "#%02x%02x%02x" \
438 set color [format "#%02x%02x%02x" \
443 set color [format "#%02x%02x%02x" \
453 -fill $color -outline $color]
455 $col itemconfigure $l -fill $color -outline $color
469 # ::tk::dialog::color::CreateSelector --
474 proc ::tk::dialog::color::CreateSelector {w sel c } {
475 upvar ::tk::dialog::color::[winfo name $w] data
484 # ::tk::dialog::color::RedrawFinalColor
486 # Combines the intensities of the three colors into the final color
488 proc ::tk::dialog::color::RedrawFinalColor {w} {
489 upvar ::tk::dialog::color::[winfo name $w] data
491 set color [format "#%02x%02x%02x" $data(red,intensity) \
494 $data(finalCanvas) configure -bg $color
495 set data(finalColor) $color
496 set data(selection) $color
503 # ::tk::dialog::color::RedrawColorBars --
505 # Only redraws the colors on the color strips that were not manipulated.
506 # Params: color of colorstrip that changed. If color is not [red|green|blue]
509 proc ::tk::dialog::color::RedrawColorBars {w colorChanged} {
510 upvar ::tk::dialog::color::[winfo name $w] data
538 # ::tk::dialog::color::StartMove --
544 # Params: sel is the selector canvas window, color is the color of the strip.
546 proc ::tk::dialog::color::StartMove {w sel color x delta {dontMove 0}} {
547 upvar ::tk::dialog::color::[winfo name $w] data
550 MoveSelector $w $sel $color $x $delta
554 # ::tk::dialog::color::MoveSelector --
563 proc ::tk::dialog::color::MoveSelector {w sel color x delta} {
564 upvar ::tk::dialog::color::[winfo name $w] data
573 set diff [expr {$x - $data($color,x)}]
574 $sel move $data($color,index) $diff 0
575 set data($color,x) [expr {$data($color,x) + $diff}]
581 # ::tk::dialog::color::ReleaseMouse
585 # Params: sel is the selector canvas, color is the color of the strip,
588 proc ::tk::dialog::color::ReleaseMouse {w sel color x delta} {
589 upvar ::tk::dialog::color::[winfo name $w] data
591 set x [MoveSelector $w $sel $color $x $delta]
593 # Determine exactly what color we are looking at.
594 set data($color,intensity) [XToRgb $w $x]
596 RedrawColorBars $w $color
599 # ::tk::dialog::color::ResizeColorbars --
604 proc ::tk::dialog::color::ResizeColorBars {w} {
605 upvar ::tk::dialog::color::[winfo name $w] data
612 foreach color [list red green blue ] {
613 $data($color,col) configure -width $data(canvasWidth)
614 DrawColorScale $w $color 1
618 # ::tk::dialog::color::HandleSelEntry --
622 proc ::tk::dialog::color::HandleSelEntry {w} {
623 upvar ::tk::dialog::color::[winfo name $w] data
626 # Check to make sure that the color is valid
627 if {[catch {set color [winfo rgb . $text]} ]} {
632 set R [expr {[lindex $color 0]/0x100}]
633 set G [expr {[lindex $color 1]/0x100}]
634 set B [expr {[lindex $color 2]/0x100}]
640 # ::tk::dialog::color::HandleRGBEntry --
644 proc ::tk::dialog::color::HandleRGBEntry {w} {
645 upvar ::tk::dialog::color::[winfo name $w] data
666 # mouse cursor enters a color bar
668 proc ::tk::dialog::color::EnterColorBar {w color} {
669 upvar ::tk::dialog::color::[winfo name $w] data
671 $data($color,sel) itemconfigure $data($color,index) -fill red
674 # mouse leaves enters a color bar
676 proc ::tk::dialog::color::LeaveColorBar {w color} {
677 upvar ::tk::dialog::color::[winfo name $w] data
679 $data($color,sel) itemconfigure $data($color,index) -fill black
684 proc ::tk::dialog::color::OkCmd {w} {
686 upvar ::tk::dialog::color::[winfo name $w] data
693 proc ::tk::dialog::color::CancelCmd {w} {