Attachment "font.tcl.addcolor.addnosize.patch" to
ticket [1531199fff]
added by
tjikkun
2006-07-30 17:54:22.
--- /usr/share/bwidget1.7.0/font.tcl~ 2006-07-30 11:28:59.000000000 +0200
+++ /usr/share/bwidget1.7.0/font.tcl 2006-07-30 12:43:37.000000000 +0200
@@ -24,8 +24,10 @@
{-type Enum dialog 0 {dialog toolbar}}
{-font TkResource "" 0 label}
+ {-initialcolor String "" 0}
{-families String "all" 1}
{-querysystem Boolean 1 0}
+ {-nosizes Boolean 0 1}
{-styles String "bold italic underline overstrike" 1}
{-command String "" 0}
{-sampletext String "Sample Text" 0}
@@ -189,7 +191,9 @@
LabelFrame::configure $labf3 -focus $subf.[lindex $_styles 0]
pack $labf1 -side left -anchor n -fill both -expand yes
- pack $labf2 -side left -anchor n -fill both -expand yes -padx 8
+ if { ![Widget::getoption "$path#SelectFont" -nosizes] } {
+ pack $labf2 -side left -anchor n -fill both -expand yes -padx 8
+ }
pack $labf3 -side left -anchor n -fill both -expand yes
set botf [frame $frame.botf -width 100 -height 50 \
@@ -204,8 +208,38 @@
-text [Widget::getoption "$path#SelectFont" -sampletext]]
place $lab -relx 0.5 -rely 0.5 -anchor c
- pack $topf -pady 4 -fill both -expand yes
- pack $botf -pady 4 -fill x
+ pack $topf -pady 4 -fill both -expand yes
+
+ if { [Widget::getoption "$path#SelectFont" -initialcolor] != ""} {
+ set thecolor [Widget::getoption "$path#SelectFont" -initialcolor]
+ set colf [frame $frame.colf]
+
+ set frc [frame $colf.frame -width 50 -height 20 -bg $thecolor -bd 0 -relief flat\
+ -highlightthickness 1 -takefocus 0 \
+ -highlightbackground black \
+ -highlightcolor black]
+
+ set script "set [list SelectFont::${path}(fontcolor)] \[tk_chooseColor -parent $colf.button -initialcolor \[set [list SelectFont::${path}(fontcolor)]\]\];\
+ SelectFont::_update [list $path]"
+
+ set but [button $colf.button -command $script \
+ -text "Color..."]
+
+ $lab configure -foreground $thecolor
+ $frc configure -bg $thecolor
+
+ pack $but -side left
+ pack $frc -side left -padx 5
+
+ set data(frc) $frc
+ set data(fontcolor) $thecolor
+
+ pack $colf -pady 4 -fill x -expand true
+
+ } else {
+ set data(fontcolor) -1
+ }
+ pack $botf -pady 4 -fill x
Dialog::add $path -name ok
Dialog::add $path -name cancel
@@ -360,13 +394,24 @@
if { [Dialog::draw $path] == 0 } {
set result [Widget::getoption "$path#SelectFont" -font]
+ set color $data(fontcolor)
+
+ if { $color == "" } {
+ set color #000000
+ }
+
} else {
set result ""
+ set color ""
}
unset data
Widget::destroy "$path#SelectFont"
destroy $path
- return $result
+ if { $color != -1 } {
+ return [list $result $color]
+ } else {
+ return $result
+ }
}
@@ -428,6 +473,14 @@
if { $type == "dialog" } {
$data(label) configure -font $font
$path:cmd configure -cursor $curs
+ if { ($data(fontcolor) != "") && ($data(fontcolor) != -1) } {
+ $data(label) configure -foreground $data(fontcolor)
+ $data(frc) configure -bg $data(fontcolor)
+ } elseif { $data(fontcolor) == "" } {
+ #If no color is selected, restore previous one
+ set data(fontcolor) [$data(label) cget -foreground]
+
+ }
} elseif { [set cmd [Widget::getoption "$path#SelectFont" -command]] != "" } {
uplevel \#0 $cmd
}