Skip to content

Commit

Permalink
v3.4.6b19
Browse files Browse the repository at this point in the history
  • Loading branch information
aplsimple committed Dec 8, 2021
1 parent b0e6068 commit 6ea1983
Show file tree
Hide file tree
Showing 17 changed files with 910 additions and 525 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Version `3.4.6 (8 Dec'21)`
- BUGFIX: -initialdir option for file chooser
- BUGFIX: default/classic/alt theme & dark CS: selected check/radio buttons' bg
- BUGFIX: treeview's ttk::style for CS=-2 (i.e. if no CS)
- BUGFIX: display redefined Ctrl+Y/D, F3
- NEW : ::apave::writeTextFile option of deleting empty files instead of saving
- NEW : ::apave::bindToEvent
- NEW : -method option to define a method in apave object
- NEW : tooltip for notebook tab
- NEW : unit tree for apave.tcl
Expand All @@ -26,6 +29,7 @@ Version `3.4.6 (8 Dec'21)`
- NEW : -padx, -pady options for entry fields of choosers
- NEW : topmost attribute in showModal depending on a window's ancestors
- NEW : cs_Active to set/get flag "no CS changes"
- CHANGE: sourcing baltip.tcl modified
- CHANGE: csMainColors includes e_menu colors
- CHANGE: test0, test1, test2 modified
- CHANGE: klnd.tcl refactored (unit tree, inits)
Expand Down
33 changes: 20 additions & 13 deletions apave.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace eval ::apave {
set _AP_VARS(MODALWIN) [list]
set _AP_VARS(LINKFONT) [list -underline 1]
set _AP_VARS(INDENT) " "
set _AP_VARS(KEY,F3) F3
set _AP_VARS(KEY,CtrlD) [list Control-D Control-d]
set _AP_VARS(KEY,CtrlY) [list Control-Y Control-y]
set _AP_VARS(KEY,AltQ) [list Alt-Q Alt-q]
Expand Down Expand Up @@ -468,9 +469,13 @@ namespace eval ::apave {

} ;# ::apave

# ________________________ source obbit.tcl _________________________ #
# ________________________ source *.tcl _________________________ #

# Let the *.tcl be sourced here just to ensure
# that apave's stuff available for them and vice versa.

source [file join $::apave::apaveDir obbit.tcl]
source [file join $::apave::apaveDir baltip baltip.tcl]

# ________________________ Creating APave oo::class _________________________ #

Expand Down Expand Up @@ -1419,14 +1424,14 @@ oo::class create ::apave::APave {
ttk::menubutton $w -menu $w.m -text [set $vname] -style TMenuButtonWest {*}$mbopts
if {$tip ne {}} {
set tip [my MC $tip]
catch {::baltip tip $w $tip}
::baltip tip $w $tip
}
menu $w.m -tearoff 0
my OptionCascade_add $w.m $vname $items $precom {*}$args
trace var $vname w \
"$w config -text \"\[[self] optionCascadeText \${$vname}\]\" ;\#"
lappend ::apave::_AP_VARS(_TRACED_$w) $vname
bind $w <ButtonPress> "+ focus $w"
::apave::bindToEvent $w <ButtonPress> focus $w
return $w.m
}
#_______________________
Expand Down Expand Up @@ -2417,11 +2422,12 @@ oo::class create ::apave::APave {
} elseif {![string match "#*" $fr]} {
set attr [my GetMC $attr]
set attr [subst $attr]
lassign [::apave::extractOptions attr -tip {} -tooltip {}] t1 t2
lassign [::apave::extractOptions attr -tip {} -tooltip {}] tip t2
set wt $w.$fr
$w add [ttk::frame $wt] {*}$attr
if {[append t1 $t2] ne {}} {
catch {::baltip::tip $w $t1 -nbktab $wt}
if {[append tip $t2] ne {}} {
set tip [my MC $tip]
::baltip::tip $w $tip -nbktab $wt
}
}
}
Expand Down Expand Up @@ -2456,7 +2462,7 @@ oo::class create ::apave::APave {
-callF2 {
if {[llength $v]==1} {set w2 $v} {set w2 [string map $v $w]}
if {[string first $w2 [bind $w "<F2>"]] < 0} {
bind $w <F2> [list + $w2 invoke]
::apave::bindToEvent $w <F2> $w2 invoke
}
}
-timeout {
Expand Down Expand Up @@ -2729,8 +2735,9 @@ oo::class create ::apave::APave {
lassign [split [string map [list $_pav(edge) $::apave::UFF] $v] $::apave::UFF] v tt vz
set tt [string map [list %l $txt] $tt]
set v [string map [list %l $txt %t $tt] $v]
if {$tt ne ""} {
catch {::baltip tip $lab $tt}
if {$tt ne {}} {
set tt [my MC $tt]
::baltip tip $lab $tt
lappend ::apave::_AP_VARS(TIMW) $lab
}
if {$inv} {
Expand Down Expand Up @@ -2878,10 +2885,10 @@ oo::class create ::apave::APave {

if {[bind $wt <<Paste>>] eq ""} {
set res " \
bind $wt <<Paste>> {+ [self] pasteText $wt} ;\
bind $wt <KP_Enter> {+ [self] onKeyTextM $wt %K %s} ;\
bind $wt <Return> {+ [self] onKeyTextM $wt %K %s} ;\
catch {bind $wt <braceright> {+ [self] onKeyTextM $wt %K}}"
::apave::bindToEvent $wt <<Paste>> [self] pasteText $wt ;\
::apave::bindToEvent $wt <KP_Enter> [self] onKeyTextM $wt %K %s ;\
::apave::bindToEvent $wt <Return> [self] onKeyTextM $wt %K %s ;\
catch {::apave::bindToEvent $wt <braceright> [self] onKeyTextM $wt %K}"
}
foreach k [::apave::getTextHotkeys CtrlD] {
append res " ; bind $wt <$k> {[self] doubleText $wt}"
Expand Down
11 changes: 7 additions & 4 deletions apavedialog.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,13 @@ oo::class create ::apave::APaveDialog {
# com1 - user's command "find first"
# com2 - user's command "find next"

set accF3 [::apave::KeyAccelerator [::apave::getTextHotkeys F3]]
if {$com1 eq ""} {set com1 "[self] InitFindInText 0 $txt; focus \[[self] Entfind\]"}
if {$com2 eq ""} {set com2 "[self] findInText 1 $txt"}
return "\$pop add separator
\$pop add command [my iconA find] -accelerator Ctrl+F -label \"Find First\" \\
-command {$com1}
\$pop add command [my iconA none] -accelerator F3 -label \"Find Next\" \\
\$pop add command [my iconA none] -accelerator $accF3 -label \"Find Next\" \\
-command {$com2}"
}

Expand All @@ -611,10 +612,12 @@ oo::class create ::apave::APaveDialog {
# pop - path to the menu
# txt - path to the text

set accD [::apave::KeyAccelerator [::apave::getTextHotkeys CtrlD]]
set accY [::apave::KeyAccelerator [::apave::getTextHotkeys CtrlY]]
return "\$pop add separator
\$pop add command [my iconA add] -accelerator Ctrl+D -label \"Double Selection\" \\
\$pop add command [my iconA add] -accelerator $accD -label \"Double Selection\" \\
-command \"[self] doubleText {$txt} 0\"
\$pop add command [my iconA delete] -accelerator Ctrl+Y -label \"Delete Line\" \\
\$pop add command [my iconA delete] -accelerator $accY -label \"Delete Line\" \\
-command \"[self] deleteLine {$txt} 0\"
\$pop add command [my iconA up] -accelerator Alt+Up -label \"Line(s) Up\" \\
-command \"[self] linesMove {$txt} -1 0\"
Expand Down Expand Up @@ -680,7 +683,7 @@ oo::class create ::apave::APaveDialog {
$w tag configure hilited -foreground #1f0000 -background #ffa073
$w tag configure hilited2 -foreground #1f0000 -background #ff6b85
bind $w <Double-ButtonPress-1> [list [self] highlight_matches $w]
bind $w <KeyRelease> [list + [self] unhighlight_matches $w]
::apave::bindToEvent $w <KeyRelease> [self] unhighlight_matches $w
bind $w <Alt-Left> "[self] seek_highlight $w 0 ; break"
bind $w <Alt-Right> "[self] seek_highlight $w 1 ; break"
foreach k [::apave::getTextHotkeys AltQ] {
Expand Down
2 changes: 1 addition & 1 deletion apaveinput.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

package require Tk

package provide apave 3.4.6b16
package provide apave 3.4.6b19

source [file join [file dirname [info script]] apavedialog.tcl]

Expand Down
70 changes: 66 additions & 4 deletions baltip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ The original code has been modified to make the tip:

* be faded/destroyed after an interval defined by a caller
* be enabled/disabled for all or specific widgets
* be disabled for a while ("sleep")
* be usable with labels, menus, text/canvas tags, notebook tabs, listbox/treeview items etc.
* be displayed at the screen's edges
* be displayed under the host widget
* be displayed as a stand-alone balloon message at given coordinates
* be displayed with given font, colors, paddings, border, relief, opacity, bell
* have -image and -compound options to display images
* have -command option to be displayed in a status bar instead of a balloon
* have -maxexp option to limit the number of tip's expositions
* have configure/cget etc. wrapped in Tcl ensemble for convenience

The video introduction to *baltip* is presented by
[baltip-1.3.mp4](https://github.com/aplsimple/baltip/releases/download/baltip-1.3/baltip-1.3.mp4) (16 Mb).
[baltip-1.3.1.mp4](https://github.com/aplsimple/baltip/releases/download/baltip-1.3.1/baltip-1.3.1.mp4) (17 Mb).

Below are several pictures just to glance at *baltip*.

Expand Down Expand Up @@ -64,6 +67,10 @@ The *treeview* can have tips per item and/or column as well as for a whole treev

<img src="https://aplsimple.github.io/en/tcl/baltip/files/btip15.png" class="media" alt="">

The *-command* option allows to display tips in a status bar instead of a balloon.

<img src="https://aplsimple.github.io/en/tcl/baltip/files/btip16.png" class="media" alt="">

*Configurable tips*. The tip configuration can be global or local (for a specific tip).

The configuring can include: font, colors, paddings, border, relief, exposition time, opacity, image (with -compound), bell.
Expand Down Expand Up @@ -155,6 +162,13 @@ If you need to switch between "per item" and "per widget" tip of listbox and tre
::baltip::tip .treeview {Common tip} -reset yes ;# sets a usual tip
::baltip::tip .treeview {::treTip %i %c} -reset yes ;# sets a callback

Some GUI objects (notebook tabs, listbox items, treeview items) have not &lt;Enter&gt; nor &lt;Leave&gt; event bindings, so that those bindings are imitated by *baltip*. Hence a problem with popup menus: when you right-click those GUI objects, *baltip::tip* and *tk_popup* might both fire, which results in a mess.

To avoid this, use *::baltip::sleep* before *tk_popup*, for example:

::baltip::sleep 1000 ;# disables tips for 1000 milliseconds
tk_popup $popupmenu $X $Y ;# calls a popup menu at $X $Y coordinates


## Balloon

Expand All @@ -179,6 +193,46 @@ For example:
set text "The balloon at the right edge of the window"
::baltip tip .win $text -geometry $geom -pause 2000 -fade 2000


## Command

The "-command" option allows to display tips in other places, for example in a status bar. At that, the command can include %t and %w wildcards, meaning "text" and "widget path". Such tips are well fit for menu items, as seen in *test.tcl*.

For example:

proc ::Status {tip} {
.labelstatus configure -text $tip
}
::baltip::tip .menu "File actions" -index 0 -command {::Status {%t}}
::baltip::tip .menu "Help, hints, Q&A, about etc." -index 1 -command {::Status {%t}}

Also, this option can be used if you need to fire some code when the mouse pointer enters or leaves a GUI object.

**Note**: the *baltip* is available for a few of GUI objects that have not &lt;Enter&gt; nor &lt;Leave&gt; bindings.

The only line

baltip::tip $w $tip -command $command

might save you other lines to fire the command at entering/leaving a GUI object. E.g. the command might highlight a GUI object entered, save its ID and unhighlight the object at leaving it.

For example:

proc ::SomeProc {tip} {
lassign [split $tip] obj ID column
if {[info exists ::OBJsaved]} {
puts "$::OBJsaved object ID=[set ::IDsaved] is left... unhighlighted..."
unset ::OBJsaved
}
if {$obj eq {}} return
set ::OBJsaved $obj
set ::IDsaved $ID
puts "Now processing $obj object with ID=$ID column=$column"
}
::baltip::tip .listbox {Listbox %i} -command {::SomeProc {%t}}
::baltip::tip .treeview {Treeview %i %c} -command {::SomeProc {%t}}


## Options

Below are listed the *baltip* options that are set with `tip` and `configure` and got with `cget`:
Expand Down Expand Up @@ -210,7 +264,9 @@ The following options are special:
* `-ctag` - name of canvas tag to tip;
* `-nbktab` - path to ttk::notebook tab to tip;
* `-geometry` - geometry (+X+Y) of the balloon;
* `-reset` - "-reset true" may be useful to set a new tip (callback or text) for listbox and treeview.
* `-reset` - "-reset true" may be useful to set a new tip (callback or text) for listbox and treeview;
* `-command` - a command to be executed, with %t (tip's text) and %w (widget's path) wildcards;
* `-maxexp` - maximum number of tip's expositions.

If `-global yes` option is used alone, it applies all global options to all registered tips. If `-global yes` option is used along with other options, only those options are applied to all registered tips.

Expand All @@ -224,6 +280,12 @@ The `-index` option may have numeric (0, 1, 2...) or symbolic form (active, end,
::baltip repaint .win.popupMenu -index active
::baltip::tip .menu "File actions" -index 0

There may be useful to define options in *text* argument of *::baltip::tip*.

For this, provide the *text* argument as a list of pairs of uppercased options' name / value including *-BALTIP* option for *tip*. For example:

::baltip tip .text "-BALTIP {Sort of diary, todos etc.} -MAXEXP 1"

As seen in the above examples, *baltip* can be used as Tcl ensemble, so that the commands may be shortened.

See more examples in *test.tcl* of [baltip.zip](https://chiselapp.com/user/aplsimple/repository/baltip/download).
Expand All @@ -236,7 +298,7 @@ The *baltip* package has been developed with help of these kind people:

* [Nicolas Bats](https://github.com/sl1200mk2) prompted to add canvas tags' tips

* [Csaba Nemethi](https://www.nemethi.de/) sent several bug fixes and advices, incl. on listbox and treeview tips
* [Csaba Nemethi](https://www.nemethi.de/) sent several bug fixes and advices, especially on listbox, treeview and menu tips

## Links

Expand All @@ -246,4 +308,4 @@ The *baltip* package has been developed with help of these kind people:

* [Reference](https://aplsimple.github.io/en/tcl/baltip/baltip.html)

* [Demo of baltip v1.3](https://github.com/aplsimple/baltip/releases/download/baltip-1.3/baltip-1.3.mp4)
* [Demo of baltip v1.3.1](https://github.com/aplsimple/baltip/releases/download/baltip-1.3.1/baltip-1.3.1.mp4)
Loading

0 comments on commit 6ea1983

Please sign in to comment.