::apaveTop

The apave software provides a sort of geometry manager for Tcl/Tk.

The apave isn't designed to replace the existing Tk geometry managers (place, pack, grid). Rather the apave tries to simplify the window layout by using their best, by means of:

  • joining the power of grid and pack
  • uniting a creation of widgets with their layout (and mostly their configuration)
  • minimizing a coder's efforts at creating / modifying / removing widgets
  • setting a natural tab order of widgets
  • providing 'mega-widgets'
  • providing 'mega-attributes', right up to the user-defined ones
  • centralizing things like icons or popup menus
  • theming both ttk and non-ttk widgets

The apave is implemented as APave oo::class, so that you can enhance it with your own inherited / mixin-ed class.

While APave oo::class allows to layout highly sophisticated windows, you can also employ its more 'earthy' descendants:

APaveDialog oo::class and APaveInput oo::class that allow you:

  • to call a variety of dialogs, optionally using a "Don't show again" checkbox and a tagged text
  • to use a variety of widgets in dialogs, with entry, text (incl. readonly and stand-alone), combobox (incl. file content), spinbox, listbox, file listbox, option cascade, tablelist, checkbutton, radiobutton and label (incl. title)
  • to resize windows neatly (however strange, not done in Tk standard dialogs)

The theming facility of apave is enabled by ObjectTheming oo::class which embraces both ttk and non-ttk widgets.

Along with standard widgets, the mentioned apave classes provide a batch of following 'mega-widgets':

  • file picker
  • saved file picker
  • directory picker
  • font picker
  • color picker
  • date picker
  • menubar
  • toolbar
  • statusbar
  • file combobox
  • file listbox
  • file viewer/editor
  • option cascade
  • e_menu
  • bartabs
  • link
  • baltip
  • gutter
  • scrolled frame
  • switch

At last, a CLI stand-alone dialog allows not only to ask "OK/Cancel" or "Yes/No" returning 1/0 but also to set environment variables to use in shell scripts.

The apave originates from the old pave package, to comply with How to build good packages ("avoid simple, obvious names for your namespace").

Let it be a sort of a-pave.

The details are in Description.


Commandsapave, Top




bindCantagToEvent [::apave]apave, Top

Binds an event on a canvas tag to a command.

bindCantagToEvent w tag event ?args?
Parameters
wthe widget's path
tagthe tag
eventthe event
argsthe command

proc ::apave::bindCantagToEvent {w tag event args} { # Binds an event on a canvas tag to a command. # w - the widget's path # tag - the tag # event - the event # args - the command ::baltip::my::BindCantagToEvent $w $tag $event {*}$args }




bindTextagToEvent [::apave]apave, Top

Binds an event on a text tag to a command.

bindTextagToEvent w tag event ?args?
Parameters
wthe widget's path
tagthe tag
eventthe event
argsthe command

proc ::apave::bindTextagToEvent {w tag event args} { # Binds an event on a text tag to a command. # w - the widget's path # tag - the tag # event - the event # args - the command ::baltip::my::BindTextagToEvent $w $tag $event {*}$args }




bindToEvent [::apave]apave, Top

Binds an event on a widget to a command.

bindToEvent w event ?args?
Parameters
wthe widget's path
eventthe event
argsthe command

proc ::apave::bindToEvent {w event args} { # Binds an event on a widget to a command. # w - the widget's path # event - the event # args - the command ::baltip::my::BindToEvent $w $event {*}$args }




blinkWidget [::apave]apave, Top

Makes a widget blink.

blinkWidget w ?fg? ?bg? ?fg2? ?bg2? ?pause? ?count? ?mode?
Parameters
wthe widget's path
fgnormal foreground color; optional, default #000
bgnormal background color; optional, default #fff
fg2blinking foreground color (if {}, stops the blinking); optional, default ""
bg2blinking background color; optional, default red
pausepause in millisec between blinkings; optional, default 1000
countmeans how many times do blinking; optional, default -1
modefor recursive calls; optional, default 1

proc ::apave::blinkWidget {w {fg #000} {bg #fff} {fg2 {}} {bg2 red} {pause 1000} {count -1} {mode 1}} { # Makes a widget blink. # w - the widget's path # fg - normal foreground color # bg - normal background color # fg2 - blinking foreground color (if {}, stops the blinking) # bg2 - blinking background color # pause - pause in millisec between blinkings # count - means how many times do blinking # mode - for recursive calls if {![winfo exists $w]} return if {$count==0 || $fg2 eq {}} { catch {after cancel $::apave::BLINKWIDGET1} catch {after cancel $::apave::BLINKWIDGET2} after idle "$w configure -foreground $fg; $w configure -background $bg" } elseif {$mode==1} { incr count -1 $w configure -foreground $fg2 $w configure -background $bg2 set ::apave::BLINKWIDGET1 [after $pause ::apave::blinkWidget $w $fg $bg $fg2 $bg2 $pause $count 2] } elseif {$mode==2} { $w configure -foreground $fg $w configure -background $bg set ::apave::BLINKWIDGET2 [after $pause ::apave::blinkWidget $w $fg $bg $fg2 $bg2 $pause $count 1] } }




countChar [::apave]apave, Top

Counts a character in a string.

countChar str ch
Parameters
stra string
cha character
Return value

Returns a number of non-escaped occurences of character ch in string str.

See also

wiki.tcl-lang.org


proc ::apave::countChar {str ch} { # Counts a character in a string. # str - a string # ch - a character # # Returns a number of non-escaped occurences of character *ch* in # string *str*. # # See also: # [wiki.tcl-lang.org](https://wiki.tcl-lang.org/page/Reformatting+Tcl+code+indentation) set icnt 0 while {[set idx [string first $ch $str]] >= 0} { set backslashes 0 set nidx $idx while {[string equal [string index $str [incr nidx -1]] \\]} { incr backslashes } if {$backslashes % 2 == 0} { incr icnt } set str [string range $str [incr idx] end] } return $icnt }




cs_Active [::apave]apave, Top

Gets/sets "is changing CS possible" flag for a whole application.

cs_Active ?flag?
Parameters
flagNot documented; optional, default ""

proc ::apave::cs_Active {{flag {}}} { # Gets/sets "is changing CS possible" flag for a whole application. if {[string is boolean -strict $flag]} { set ::apave::_CS_(isActive) $flag } return $::apave::_CS_(isActive) }




cs_Max [::apave]apave, Top

Gets a maximum index of available color schemes

cs_Max

proc ::apave::cs_Max {} { # Gets a maximum index of available color schemes return [expr {[llength $::apave::_CS_(ALL)] - 1}] }




cs_MaxBasic [::apave]apave, Top

Gets a maximum index of basic color schemes

cs_MaxBasic

proc ::apave::cs_MaxBasic {} { # Gets a maximum index of basic color schemes return $::apave::_CS_(STDCS) }




cs_Min [::apave]apave, Top

Gets a minimum index of available color schemes

cs_Min

proc ::apave::cs_Min {} { # Gets a minimum index of available color schemes return $::apave::_CS_(MINCS) }




cs_Non [::apave]apave, Top

Gets non-existent CS index

cs_Non

proc ::apave::cs_Non {} { # Gets non-existent CS index return -3 }




endWM [::apave]apave, Top

Finishes the window management by apave, closing and clearing all.

endWM ?args?
Parameters
argsif any set, means "ask if apave's WM is finished"

proc ::apave::endWM {args} { # Finishes the window management by apave, closing and clearing all. # args - if any set, means "ask if apave's WM is finished" variable _PU_opts if {[llength $args]} { return [expr {[info exists _PU_opts(_ENDWM_)]}] } # Check existing windows, except for the first one. while {1} { set i [expr {[llength $_PU_opts(_MODALWIN_)] - 1}] if {$i>0} { lassign [lindex $_PU_opts(_MODALWIN_) $i] w var if {[winfo exists $w]} {set $var 0} catch {set _PU_opts(_MODALWIN_) [lreplace $_PU_opts(_MODALWIN_) $i $i]} } else { break } } set _PU_opts(_ENDWM_) yes }




error [::apave]apave, Top

Gets the error's message at reading/writing.

error ?fileName?
Parameters
fileNameif set, return a full error messageat opening file; optional, default ""

proc ::apave::error {{fileName {}}} { # Gets the error's message at reading/writing. # fileName - if set, return a full error messageat opening file variable _PU_opts if {$fileName eq ""} { return $_PU_opts(_ERROR_) } return "Error of access to\n\"$fileName\"\n\n$_PU_opts(_ERROR_)" }




eventOnText [::apave]apave, Top

Generates an event on a text, saving its current index in hl_tcl.

eventOnText w ev
Parameters
wtext widget's path
evevent
Description

The hl_tcl needs to call MemPos before any action changing the text.


proc ::apave::eventOnText {w ev} { # Generates an event on a text, saving its current index in hl_tcl. # w - text widget's path # ev - event # The hl_tcl needs to call MemPos before any action changing the text. catch {::hl_tcl::my::MemPos $w} event generate $w $ev }




extractOptions [::apave]apave, Top

Gets options' values and removes the options from the input list.

extractOptions optsVar ?args?
Parameters
optsVarvariable name for the list of options and values
argslist of "option / default value" pairs
Return value

Returns a list of options' values, according to args.

See also

parseOptions


proc ::apave::extractOptions {optsVar args} { # Gets options' values and removes the options from the input list. # optsVar - variable name for the list of options and values # args - list of "option / default value" pairs # # Returns a list of options' values, according to args. # # See also: parseOptions upvar 1 $optsVar opts set retlist [::apave::parseOptions $opts {*}$args] foreach {o v} $args { set opts [::apave::removeOptions $opts $o] } return $retlist }




getN [::apave]apave, Top

Gets a number from a string

getN sn ?defn? ?min? ?max?
Parameters
snstring containing a number
defndefault value when sn is not a number; optional, default 0
minminimal value allowed; optional, default ""
maxmaximal value allowed; optional, default ""

proc ::apave::getN {sn {defn 0} {min {}} {max {}}} { # Gets a number from a string # sn - string containing a number # defn - default value when sn is not a number # min - minimal value allowed # max - maximal value allowed if {$sn eq "" || [catch {set sn [expr {$sn}]}]} {set sn $defn} if {$max ne ""} { set sn [expr {min($max,$sn)}] } if {$min ne ""} { set sn [expr {max($min,$sn)}] } return $sn }




getOption [::apave]apave, Top

Extracts one option from an option list.

getOption optname ?args?
Parameters
optnameoption name
argsoption list
Description

set options [list -name some -value "any value" -tip "some tip"] set optvalue [::apave::getOption -tip {*}$options]
Return value

Returns an option value or "". Example:


proc ::apave::getOption {optname args} { # Extracts one option from an option list. # optname - option name # args - option list # Returns an option value or "". # Example: # set options [list -name some -value "any value" -tip "some tip"] # set optvalue [::apave::getOption -tip {*}$options] set optvalue [lindex [::apave::parseOptions $args $optname ""] 0] return $optvalue }




getProperty [::apave]apave, Top

Gets a property's value as "application-wide".

getProperty name ?defvalue?
Parameters
namename of property
defvaluedefault value; optional, default ""
Description

If the property had been set, the method returns its value.

Otherwise, the method returns the default value ($defvalue).


proc ::apave::getProperty {name {defvalue {}}} { # Gets a property's value as "application-wide". # name - name of property # defvalue - default value # # If the property had been set, the method returns its value. # # Otherwise, the method returns the default value (`$defvalue`). variable _AP_Properties if {[info exists _AP_Properties($name)]} { return $_AP_Properties($name) } return $defvalue }




getTextHotkeys [::apave]apave, Top

Gets upper & lower keys for a hot key.

getTextHotkeys key
Parameters
keythe hot key

proc ::apave::getTextHotkeys {key} { # Gets upper & lower keys for a hot key. # key - the hot key variable _AP_VARS if {![info exist _AP_VARS(KEY,$key)]} {return [list]} set keys $_AP_VARS(KEY,$key) if {[llength $keys]==1} { if {[set i [string last - $keys]]>0} { set lt [string range $keys $i+1 end] if {[string length $lt]==1} { ;# for lower case of letters set keys "[string range $keys 0 $i][string toupper $lt]" lappend keys "[string range $keys 0 $i][string tolower $lt]" } } } return $keys }




iconData [::apave]apave, Top

Gets an icon's data.

iconData ?icon? ?iconset?
Parameters
iconicon's name; optional, default info
iconsetone of small/middle/large; optional, default ""
Return value

Returns data of the icon.


proc ::apave::iconData {{icon info} {iconset {}}} { # Gets an icon's data. # icon - icon's name # iconset - one of small/middle/large # Returns data of the icon. variable _AP_IMG iconImage -init if {$iconset ne {} && "_AP_IMG(img$icon-$iconset)" in [image names]} { return [set _AP_IMG($icon-$iconset)] } return [set _AP_IMG($icon)] }




iconImage [::apave]apave, Top

Gets a defined icon's image or list of icons. If icon equals to "-init", initializes apave's icon set.

iconImage ?icon? ?iconset? ?doit?
Parameters
iconicon's name; optional, default ""
iconsetone of small/middle/large; optional, default small
doitforce the initialization; optional, default no
Return value

Returns the icon's image or, if icon is blank, a list of icons available in apave.


proc ::apave::iconImage {{icon {}} {iconset small} {doit no}} { # Gets a defined icon's image or list of icons. # If *icon* equals to "-init", initializes apave's icon set. # icon - icon's name # iconset - one of small/middle/large # doit - force the initialization # Returns the icon's image or, if *icon* is blank, a list of icons # available in *apave*. variable _AP_IMG variable _AP_ICO if {$icon eq {}} {return $_AP_ICO} proc imagename {icon} { # Get a defined icon's image name return _AP_IMG(img$icon) } variable apaveDir if {![array size _AP_IMG] || $doit} { # Make images of icons source [file join $apaveDir apaveimg.tcl] if {$iconset ne "small"} { foreach ic $_AP_ICO { ;# small icons best fit for menus set _AP_IMG($ic-small) [set _AP_IMG($ic)] } if {$iconset eq "middle"} { source [file join $apaveDir apaveimg2.tcl] } else { source [file join $apaveDir apaveimg2.tcl] ;# TODO } } foreach ic $_AP_ICO { if {[catch {image create photo [imagename $ic] -data [set _AP_IMG($ic)]}]} { # some png issues on old Tk image create photo [imagename $ic] -data [set _AP_IMG(none)] } elseif {$iconset ne "small"} { image create photo [imagename $ic-small] -data [set _AP_IMG($ic-small)] } } } if {$icon eq "-init"} {return $_AP_ICO} ;# just to get to icons if {$icon ni $_AP_ICO} {set icon [lindex $_AP_ICO 0]} if {$iconset eq "small" && "_AP_IMG(img$icon-small)" in [image names]} { set icon $icon-small } return [imagename $icon] }




InfoFind [::apave]apave, Top

Searches data of a window in a list of registered windows.

InfoFind w modal
Parameters
wroot window's path
modalyes, if the window is modal
Description

Returns: the window's path or "" if not found.

See also

InfoWindow


proc ::apave::InfoFind {w modal} { # Searches data of a window in a list of registered windows. # w - root window's path # modal - yes, if the window is modal # Returns: the window's path or "" if not found. # See also: InfoWindow variable _PU_opts foreach winfo [lrange $_PU_opts(_MODALWIN_) 1 end] { ;# skip 1st window incr i lassign $winfo w1 var1 modal1 if {[winfo exists $w1]} { if {[string first $w $w1]==0 && $modal==$modal1} { return $w1 } } else { catch {set _PU_opts(_MODALWIN_) [lreplace $_PU_opts(_MODALWIN_) $i $i]} } } return {} }




InfoWindow [::apave]apave, Top

Registers/unregisters windows. Also sets/gets 'count of open modal windows'.

InfoWindow ?val? ?w? ?modal? ?var? ?regist?
Parameters
valcurrent number of open modal windows; optional, default ""
wroot window's path; optional, default .
modalyes, if the window is modal; optional, default no
varvariable's name for tkwait; optional, default ""
registyes or no for registering/unregistering; optional, default no
See also

APave::showWindow


proc ::apave::InfoWindow {{val {}} {w .} {modal no} {var {}} {regist no}} { # Registers/unregisters windows. Also sets/gets 'count of open modal windows'. # val - current number of open modal windows # w - root window's path # modal - yes, if the window is modal # var - variable's name for tkwait # regist - yes or no for registering/unregistering # See also: APave::showWindow variable _PU_opts if {$modal || $regist} { set info [list $w $var $modal] set i [lsearch -exact $_PU_opts(_MODALWIN_) $info] if {$regist} { lappend _PU_opts(_MODALWIN_) $info } else { catch {set _PU_opts(_MODALWIN_) [lreplace $_PU_opts(_MODALWIN_) $i $i]} } set res [IntStatus . MODALS $val] } else { set res [IntStatus . MODALS] } return $res }




initPOP [::apave]apave, Top

Initializes system popup menu (if possible) to call it in a window.

initPOP w
Parameters
wwindow's name

proc ::apave::initPOP {w} { # Initializes system popup menu (if possible) to call it in a window. # w - window's name bind $w <KeyPress> { if {"%K" eq "Menu"} { if {[winfo exists [set w [focus]]]} { event generate $w <Button-3> -rootx [winfo pointerx .] -rooty [winfo pointery .] } } } }




initStyles [::apave]apave, Top

Initializes miscellaneous styles, e.g. button's.

initStyles

proc ::apave::initStyles {} { # Initializes miscellaneous styles, e.g. button's. ::apave::obj create_Fonts ttk::style configure TButtonWest {*}[ttk::style configure TButton] ttk::style configure TButtonWest -anchor w -font $::apave::FONTMAIN ttk::style map TButtonWest {*}[ttk::style map TButton] ttk::style layout TButtonWest [ttk::style layout TButton] ttk::style configure TButtonBold {*}[ttk::style configure TButton] ttk::style configure TButtonBold -font $::apave::FONTMAINBOLD ttk::style map TButtonBold {*}[ttk::style map TButton] ttk::style layout TButtonBold [ttk::style layout TButton] ttk::style configure TButtonWestBold {*}[ttk::style configure TButton] ttk::style configure TButtonWestBold -anchor w -font $::apave::FONTMAINBOLD ttk::style map TButtonWestBold {*}[ttk::style map TButton] ttk::style layout TButtonWestBold [ttk::style layout TButton] ttk::style configure TButtonWestHL {*}[ttk::style configure TButton] ttk::style configure TButtonWestHL -anchor w -foreground [lindex [obj csGet] 4] ttk::style map TButtonWestHL {*}[ttk::style map TButton] ttk::style layout TButtonWestHL [ttk::style layout TButton] ttk::style configure TMenuButtonWest {*}[ttk::style configure TMenubutton] ttk::style configure TMenuButtonWest -anchor w -font $::apave::FONTMAIN -relief raised ttk::style map TMenuButtonWest {*}[ttk::style map TMenubutton] ttk::style layout TMenuButtonWest [ttk::style layout TMenubutton] }




initStylesFS [::apave]apave, Top

Initializes miscellaneous styles, e.g. button's.

initStylesFS ?args?
Parameters
argsfont options ("name value" pairs)

proc ::apave::initStylesFS {args} { # Initializes miscellaneous styles, e.g. button's. # args - font options ("name value" pairs) ::apave::obj create_Fonts set font "$::apave::FONTMAIN $args" set fontB "$::apave::FONTMAINBOLD $args" ttk::style configure TLabelFS {*}[ttk::style configure TLabel] ttk::style configure TLabelFS -font $font ttk::style map TLabelFS {*}[ttk::style map TLabel] ttk::style layout TLabelFS [ttk::style layout TLabel] ttk::style configure TCheckbuttonFS {*}[ttk::style configure TCheckbutton] ttk::style configure TCheckbuttonFS -font $font ttk::style map TCheckbuttonFS {*}[ttk::style map TCheckbutton] ttk::style layout TCheckbuttonFS [ttk::style layout TCheckbutton] ttk::style configure TComboboxFS {*}[ttk::style configure TCombobox] ttk::style configure TComboboxFS -font $font ttk::style map TComboboxFS {*}[ttk::style map TCombobox] ttk::style layout TComboboxFS [ttk::style layout TCombobox] ttk::style configure TRadiobuttonFS {*}[ttk::style configure TRadiobutton] ttk::style configure TRadiobuttonFS -font $font ttk::style map TRadiobuttonFS {*}[ttk::style map TRadiobutton] ttk::style layout TRadiobuttonFS [ttk::style layout TRadiobutton] ttk::style configure TButtonWestFS {*}[ttk::style configure TButton] ttk::style configure TButtonWestFS -anchor w -font $font ttk::style map TButtonWestFS {*}[ttk::style map TButton] ttk::style layout TButtonWestFS [ttk::style layout TButton] ttk::style configure TButtonBoldFS {*}[ttk::style configure TButton] ttk::style configure TButtonBoldFS -font $fontB ttk::style map TButtonBoldFS {*}[ttk::style map TButton] ttk::style layout TButtonBoldFS [ttk::style layout TButton] ttk::style configure TButtonWestBoldFS {*}[ttk::style configure TButton] ttk::style configure TButtonWestBoldFS -anchor w -font $fontB ttk::style map TButtonWestBoldFS {*}[ttk::style map TButton] ttk::style layout TButtonWestBoldFS [ttk::style layout TButton] }




InitTheme [::apave]apave, Top

Initializes app's theme.

InitTheme intheme libdir
Parameters
inthemename of the theme
libdirroot directory of themes (where 'theme' subdirectory is)
Return value

Returns a list of theme name and label's border (for status bar). The returned values are used in ::apave::initWM procedure.


proc ::apave::InitTheme {intheme libdir} { # Initializes app's theme. # intheme - name of the theme # libdir - root directory of themes (where 'theme' subdirectory is) # Returns a list of theme name and label's border (for status bar). # The returned values are used in ::apave::initWM procedure. set theme {} switch -glob -- $intheme { azure* - sun-valley* { set i [string last - $intheme] set name [string range $intheme 0 $i-1] set type [string range $intheme $i+1 end] catch {source [file join $libdir theme $name $name.tcl]} catch {set_theme $type} set lbd 0 } forest* { set i [string last - $intheme] set name [string range $intheme 0 $i-1] set type [string range $intheme $i+1 end] catch { source [file join $libdir theme $name $intheme.tcl] set theme $intheme } set lbd 0 } awdark - awlight { global auto_path lappend auto_path [file join $libdir theme awthemes-10.4.0] package require awthemes package require ttk::theme::$intheme set theme $intheme set lbd 1 } default { set theme $intheme set lbd 1 } } return [list $theme $lbd] }




initWM [::apave]apave, Top

Initializes Tcl/Tk session. Used to be called at the beginning of it.

initWM ?args?
Parameters
argsoptions ("name value" pairs)

proc ::apave::initWM {args} { # Initializes Tcl/Tk session. Used to be called at the beginning of it. # args - options ("name value" pairs) if {!$::apave::_CS_(initWM)} return lassign [::apave::parseOptions $args -cursorwidth $::apave::cursorwidth -theme {clam} -buttonwidth -8 -buttonborder 1 -labelborder 0 -padding 1] cursorwidth theme buttonwidth buttonborder labelborder padding set ::apave::_CS_(initWM) 0 set ::apave::_CS_(CURSORWIDTH) $cursorwidth set ::apave::_CS_(LABELBORDER) $labelborder wm withdraw . if {$::tcl_platform(platform) eq {windows}} { wm attributes . -alpha 0.0 } # for default theme: only most common settings set tfg1 $::apave::_CS_(!FG) set tbg1 $::apave::_CS_(!BG) if {$theme ne {}} {catch {ttk::style theme use $theme}} ttk::style map . -selectforeground [list !focus $tfg1 {focus active} $tfg1] -selectbackground [list !focus $tbg1 {focus active} $tbg1] ttk::style configure . -selectforeground $tfg1 -selectbackground $tbg1 # configure separate widget types ttk::style configure TButton -anchor center -width $buttonwidth -relief raised -borderwidth $buttonborder -padding $padding ttk::style configure TMenubutton -width 0 -padding 0 # TLabel's standard style saved for occasional uses ttk::style configure TLabelSTD {*}[ttk::style configure TLabel] ttk::style configure TLabelSTD -anchor w ttk::style map TLabelSTD {*}[ttk::style map TLabel] ttk::style layout TLabelSTD [ttk::style layout TLabel] # ... TLabel new style ttk::style configure TLabel -borderwidth $labelborder -padding $padding # ... Treeview colors set twfg [ttk::style map Treeview -foreground] set twfg [::apave::putOption selected $tfg1 {*}$twfg] set twbg [ttk::style map Treeview -background] set twbg [::apave::putOption selected $tbg1 {*}$twbg] ttk::style map Treeview -foreground $twfg ttk::style map Treeview -background $twbg # ... TCombobox colors ttk::style map TCombobox -fieldforeground [list {active focus} $tfg1 readonly $tfg1 disabled grey] ttk::style map TCombobox -fieldbackground [list {active focus} $tbg1 {readonly focus} $tbg1 {readonly !focus} white] initPOP . initStyles }




IntStatus [::apave]apave, Top

Sets/gets a status of window. The status is an integer assigned to a name.

IntStatus w ?name? ?val?
Parameters
wwindow's path
namename of status; optional, default status
valif blank, to get a value of status; otherwise a value to set; optional, default ""
Description

Default value of status is 0.

Return value

Returns an old value of status.

See also

WindowStatus


proc ::apave::IntStatus {w {name status} {val {}}} { # Sets/gets a status of window. The status is an integer assigned to a name. # w - window's path # name - name of status # val - if blank, to get a value of status; otherwise a value to set # Default value of status is 0. # Returns an old value of status. # See also: WindowStatus set old [WindowStatus $w $name {} 0] if {$val ne {}} {WindowStatus $w $name $val 1} return $old }




KeyAccelerator [::apave]apave, Top

Returns a key accelerator.

KeyAccelerator acc
Parameters
acckey name, may contain 2 items (e.g. Control-D Control-d)
Return value

Returns a key accelerator.


proc ::apave::KeyAccelerator {acc} { # Returns a key accelerator. # acc - key name, may contain 2 items (e.g. Control-D Control-d) set acc [lindex $acc 0] return [string map {Control Ctrl - + bracketleft [ bracketright ]} $acc] }




LbxSelect [::apave]apave, Top

Selects a listbox item.

LbxSelect w idx
Parameters
wlistbox's path
idxitem index

proc ::apave::LbxSelect {w idx} { # Selects a listbox item. # w - listbox's path # idx - item index $w activate $idx $w see $idx if {[$w cget -selectmode] in {single browse}} { $w selection clear 0 end $w selection set $idx event generate $w <<ListboxSelect>> } }




logMessage [::apave]apave, Top

Logs messages to a log file.

logMessage msg ?lev?
Parameters
msgthe message
levmaximum level for [info level] to introspect calls; optional, default 16
Description

A log file's name is set by _PU_opts(_LOGFILE_). If it's blank, no logging is made.


proc ::apave::logMessage {msg {lev 16}} { # Logs messages to a log file. # msg - the message # lev - maximum level for [info level] to introspect calls # A log file's name is set by _PU_opts(_LOGFILE_). If it's blank, # no logging is made. variable _PU_opts; if {$_PU_opts(_LOGFILE_) eq {}} return set chan [open $_PU_opts(_LOGFILE_) a] set dt [clock format [clock seconds] -format {%d%b'%y %T}] set msg "$dt $msg" for {set i $lev} {$i>0} {incr i -1} { catch { lassign [info level -$i] p1 p2 if {$p1 eq {my}} {append p1 " $p2"} append msg " / $p1" } } puts $chan $msg close $chan puts "$_PU_opts(_LOGFILE_) - $msg" }




logName [::apave]apave, Top

Sets a log file's name.

logName fname
Parameters
fnamefile name
Description

If fname is {}, disables logging.


proc ::apave::logName {fname} { # Sets a log file's name. # fname - file name # If fname is {}, disables logging. variable _PU_opts; set _PU_opts(_LOGFILE_) [file normalize $fname] }




mc [::apave]apave, Top

Gets a localized version of a message.

mc msg
Parameters
msgthe message

proc ::apave::mc {msg} { # Gets a localized version of a message. # msg - the message variable _MC_ if {[info exists _MC_($msg)]} {return $_MC_($msg)} return $msg }




obj [::apave]apave, Top

Calls a method of APaveInput class.

obj com ?args?
Parameters
coma method
argsarguments of the method
Description

It can (and must) be used only for temporary tasks. For persistent tasks, use a "normal" apave object.

Return value

Returns the command's result.


proc ::apave::obj {com args} { # Calls a method of APaveInput class. # com - a method # args - arguments of the method # # It can (and must) be used only for temporary tasks. # For persistent tasks, use a "normal" apave object. # # Returns the command's result. variable _OBJ_ if {$_OBJ_ eq {}} {set _OBJ_ [::apave::APaveInput new]} if {[set exported [expr {$com eq "EXPORT"}]]} { set com [lindex $args 0] set args [lrange $args 1 end] oo::objdefine $_OBJ_ "export $com" } set res [$_OBJ_ $com {*}$args] if {$exported} { oo::objdefine $_OBJ_ "unexport $com" } return $res }




openDoc [::apave]apave, Top

Opens a document.

openDoc url
Parameters
urldocument's file name, www link, e-mail etc.

proc ::apave::openDoc {url} { # Opens a document. # url - document's file name, www link, e-mail etc. set commands {xdg-open open start} foreach opener $commands { if {$opener eq "start"} { set command [list {*}[auto_execok start] {}] } else { set command [auto_execok $opener] } if {[string length $command]} { break } } if {[string length $command] == 0} { puts "ERROR: couldn't find any opener" } # remove the tailing " &" (as e_menu can set) set url [string trimright $url] if {[string match "* &" $url]} {set url [string range $url 0 end-2]} set url [string trim $url] if {[catch {exec -- {*}$command $url &} error]} { puts "ERROR: couldn't execute '$command':\n$error" } }




parseOptions [::apave]apave, Top

Parses argument list containing options.

parseOptions opts ?args?
Parameters
optslist of options and values
argslist of "option / default value" pairs
Description

It's the same as parseOptionsFile, excluding the file name stuff.

Return value

Returns a list of options' values, according to args.

See also

parseOptionsFile


proc ::apave::parseOptions {opts args} { # Parses argument list containing options. # opts - list of options and values # args - list of "option / default value" pairs # # It's the same as parseOptionsFile, excluding the file name stuff. # # Returns a list of options' values, according to args. # # See also: parseOptionsFile lassign [::apave::parseOptionsFile 0 $opts {*}$args] tmp foreach {nam val} $tmp { lappend retlist $val } return $retlist }




parseOptionsFile [::apave]apave, Top

Parses argument list containing options and (possibly) a file name.

parseOptionsFile strict inpargs ?args?
Parameters
strictif 1, only 'args' options are allowed, all the rest of inpargs to be a file name - if 2, the 'args' options replace the appropriate options of 'inpargs'
inpargslist of options, values and a file name
argslist of default options
Description

The inpargs list contains:

  • option names beginning with "-"
  • option values following their names (may be missing)
  • "--" denoting the end of options
  • file name following the options (may be missing)

The args parameter contains the pairs:

  • option name (e.g., "-dir")
  • option default value

If the args option value is equal to =NONE=, the inpargs option is considered to be a single option without a value and, if present in inpargs, its value is returned as "yes".

If any option of inpargs is absent in args and strict==1, the rest of inpargs is considered to be a file name.

The proc returns a list of two items:

  • an option list got from args/inpargs according to 'strict'
  • a file name from inpargs or {} if absent

Examples see in tests/obbit.test.


proc ::apave::parseOptionsFile {strict inpargs args} { # Parses argument list containing options and (possibly) a file name. # strict - if 0, 'args' options will be only counted for, # other options are skipped # strict - if 1, only 'args' options are allowed, # all the rest of inpargs to be a file name # - if 2, the 'args' options replace the # appropriate options of 'inpargs' # inpargs - list of options, values and a file name # args - list of default options # # The inpargs list contains: # - option names beginning with "-" # - option values following their names (may be missing) # - "--" denoting the end of options # - file name following the options (may be missing) # # The *args* parameter contains the pairs: # - option name (e.g., "-dir") # - option default value # # If the *args* option value is equal to =NONE=, the *inpargs* option # is considered to be a single option without a value and, # if present in inpargs, its value is returned as "yes". # # If any option of *inpargs* is absent in *args* and strict==1, # the rest of *inpargs* is considered to be a file name. # # The proc returns a list of two items: # - an option list got from args/inpargs according to 'strict' # - a file name from inpargs or {} if absent # # Examples see in tests/obbit.test. variable _PU_opts set actopts true array set argarray "$args yes yes" ;# maybe, tail option without value if {$strict==2} { set retlist $inpargs } else { set retlist $args } set retfile {} for {set i 0} {$i < [llength $inpargs]} {incr i} { set parg [lindex $inpargs $i] if {$actopts} { if {$parg eq "--"} { set actopts false } elseif {[catch {set defval $argarray($parg)}]} { if {$strict==1} { set actopts false append retfile $parg " " } else { incr i } } else { if {$strict==2} { if {$defval == $_PU_opts(-NONE)} { set defval yes } incr i } else { if {$defval == $_PU_opts(-NONE)} { set defval yes } else { set defval [lindex $inpargs [incr i]] } } set ai [lsearch -exact $retlist $parg] incr ai set retlist [lreplace $retlist $ai $ai $defval] } } else { append retfile $parg " " } } return [list $retlist [string trimright $retfile]] }




precedeWidgetName [::apave]apave, Top

Adds a preceding name to a tail name of widget.

precedeWidgetName widname prename
Parameters
widnamewidget's full name
prenamepreceding name
Description

Useful at getting a entry/button name of chooser.


proc ::apave::precedeWidgetName {widname prename} { # Adds a preceding name to a tail name of widget. # widname - widget's full name # prename - preceding name # Useful at getting a entry/button name of chooser. # Example: # set wentry [::apave::precedeWidgetName [$pobj DirToChoose] ent] # See also: APave::Replace_chooser set p [string last . $widname] set res [string range $widname 0 $p] append res $prename [string range $widname $p+1 end] return $res }




putOption [::apave]apave, Top

Replaces or adds one option to an option list.

putOption optname optvalue ?args?
Parameters
optnameoption name
optvalueoption value
argsoption list
Return value

Returns an updated option list.


proc ::apave::putOption {optname optvalue args} { # Replaces or adds one option to an option list. # optname - option name # optvalue - option value # args - option list # Returns an updated option list. set optlist {} set doadd true foreach {a v} $args { if {$a eq $optname} { set v $optvalue set doadd false } lappend optlist $a $v } if {$doadd} {lappend optlist $optname $optvalue} return $optlist }




readTextFile [::apave]apave, Top

Reads a text file.

readTextFile fileName ?varName? ?doErr?
Parameters
fileNamefile name
varNamevariable name for file content or "" optional, default ""
doErrif 'true', exit at errors with error message; optional, default 0
Return value

Returns file contents or "".


proc ::apave::readTextFile {fileName {varName {}} {doErr 0}} { # Reads a text file. # fileName - file name # varName - variable name for file content or "" # doErr - if 'true', exit at errors with error message # # Returns file contents or "". variable _PU_opts if {$varName ne {}} {upvar $varName fvar} if {[catch {set chan [open $fileName]} _PU_opts(_ERROR_)]} { if {$doErr} {error [::apave::error $fileName]} set fvar {} } else { ::apave::textChanConfigure $chan {} auto ;# let EOL be autodetected set fvar [read $chan] close $chan logMessage "read $fileName" } return $fvar }




removeOptions [::apave]apave, Top

Removes some options from a list of options.

removeOptions options ?args?
Parameters
optionslist of options and values
argslist of option names to remove
Description

The options may contain "key value" pairs and "alone" options without values.

To remove "key value" pairs, key should be an exact name.

To remove an "alone" option, key should be a glob pattern with *.


proc ::apave::removeOptions {options args} { # Removes some options from a list of options. # options - list of options and values # args - list of option names to remove # # The `options` may contain "key value" pairs and "alone" options # without values. # # To remove "key value" pairs, `key` should be an exact name. # # To remove an "alone" option, `key` should be a glob pattern with `*`. foreach key $args { if {[set i [lsearch -exact $options $key]]>-1} { catch { # remove a pair "option value" set options [lreplace $options $i $i] set options [lreplace $options $i $i] } } elseif {[string first * $key]>=0 && [set i [lsearch -glob $options $key]]>-1} { # remove an option only set options [lreplace $options $i $i] } } return $options }




setAppIcon [::apave]apave, Top

Sets application's icon.

setAppIcon win ?winicon?
Parameters
winpath to a window of application
winicondata of icon; optional, default ""
Description

The winicon may be a contents of variable (as supposed by default) or a file's name containing th image data. If it fails to find an image in either, no icon is set.


proc ::apave::setAppIcon {win {winicon {}}} { # Sets application's icon. # win - path to a window of application # winicon - data of icon # The *winicon* may be a contents of variable (as supposed by default) or # a file's name containing th image data. # If it fails to find an image in either, no icon is set. set appIcon {} if {$winicon ne {}} { if {[catch {set appIcon [image create photo -data $winicon]}]} { catch {set appIcon [image create photo -file $winicon]} } } if {$appIcon ne {}} {wm iconphoto $win -default $appIcon} }




setProperty [::apave]apave, Top

Sets a property's value as "application-wide".

setProperty name ?args?
Parameters
namename of property
argsvalue of property
Description

If args is omitted, the method returns a property's value.

If args is set, the method sets a property's value as $args.


proc ::apave::setProperty {name args} { # Sets a property's value as "application-wide". # name - name of property # args - value of property # # If *args* is omitted, the method returns a property's value. # # If *args* is set, the method sets a property's value as $args. variable _AP_Properties switch -exact [llength $args] { 0 {return [getProperty $name]} 1 {return [set _AP_Properties($name) [lindex $args 0]]} } puts -nonewline stderr "Wrong # args: should be \"::apave::setProperty propertyname ?value?\"" return -code error }




setTextHotkeys [::apave]apave, Top

Sets new key combinations for some operations on text widgets.

setTextHotkeys key value
Parameters
keyctrlD for "double selection", ctrlY for "delete line" operation
valuelist of new key combinations

proc ::apave::setTextHotkeys {key value} { # Sets new key combinations for some operations on text widgets. # key - ctrlD for "double selection", ctrlY for "delete line" operation # value - list of new key combinations variable _AP_VARS set _AP_VARS(KEY,$key) $value }




setTextIndent [::apave]apave, Top

Sets an indenting for text widgets.

setTextIndent len ?padchar?
Parameters
lenlength of indenting
padcharindenting character; optional, default

proc ::apave::setTextIndent {len {padchar { }}} { # Sets an indenting for text widgets. # len - length of indenting # padchar - indenting character variable _AP_VARS if {$padchar ne "\t"} {set padchar { }} set _AP_VARS(INDENT) [string repeat $padchar $len] }




shadowAllowed [::apave]apave, Top

Sets/gets "shadowing" mode.

shadowAllowed ?val? ?w?
Parameters
valinteger (0/1); optional, default ""
wwindow's path; optional, default .
Description

The mode may be used at processing "shadow" (grey) of color scheme.

Return value

Returns an old value of shadowing mode.


proc ::apave::shadowAllowed {{val {}} {w .}} { # Sets/gets "shadowing" mode. # val - integer (0/1) # w - window's path # The mode may be used at processing "shadow" (grey) of color scheme. # Returns an old value of shadowing mode. return [IntStatus $w SHADOW $val] }




textChanConfigure [::apave]apave, Top

Configures a channel for text file.

textChanConfigure channel ?coding? ?eol?
Parameters
channelthe channel
codingif set, defines encoding of the file; optional, default ""
eolif set, defines EOL of the file; optional, default ""

proc ::apave::textChanConfigure {channel {coding {}} {eol {}}} { # Configures a channel for text file. # channel - the channel # coding - if set, defines encoding of the file # eol - if set, defines EOL of the file if {$coding eq {}} { chan configure $channel -encoding utf-8 } else { chan configure $channel -encoding $coding } if {$eol eq {}} { chan configure $channel {*}[::apave::textEOL translation] } else { chan configure $channel -translation $eol } }




textEOL [::apave]apave, Top

Gets/sets End-of-Line for text reqding/writing.

textEOL ?EOL?
Parameters
EOLLF, CR, CRLF or {}; optional, default -
Description

If EOL omitted or equals to {} or "-", return the current EOL. If EOL equals to "translation", return -translation option or {}.


proc ::apave::textEOL {{EOL -}} { # Gets/sets End-of-Line for text reqding/writing. # EOL - LF, CR, CRLF or {} # If EOL omitted or equals to {} or "-", return the current EOL. # If EOL equals to "translation", return -translation option or {}. variable _PU_opts if {$EOL eq "-"} {return $_PU_opts(_EOL_)} if {$EOL eq "translation"} { if {$_PU_opts(_EOL_) eq ""} {return ""} return "-translation $_PU_opts(_EOL_)" } set _PU_opts(_EOL_) [string trim [string tolower $EOL]] }




textsplit [::apave]apave, Top

Splits a text's contents by EOLs. Those inventors of EOLs...

textsplit textcont
Parameters
textconttext's contents

proc ::apave::textsplit {textcont} { # Splits a text's contents by EOLs. Those inventors of EOLs... # textcont - text's contents return [split [string map [list \r\n \n \r \n] $textcont] \n] }




TreSelect [::apave]apave, Top

Selects a treeview item.

TreSelect w idx
Parameters
wtreeview's path
idxitem index

proc ::apave::TreSelect {w idx} { # Selects a treeview item. # w - treeview's path # idx - item index set items [$w children {}] catch { set it [lindex $items $idx] $w see $it $w focus $it $w selection set $it ;# generates <<TreeviewSelect>> } }




WindowStatus [::apave]apave, Top

Sets/gets a status of window. The status is a value assigned to a name.

WindowStatus w name ?val? ?defval?
Parameters
wwindow's path
namename of status
valif blank, to get a value of status; otherwise a value to set; optional, default ""
defvaldefault value (actual if the status not set beforehand); optional, default ""
Return value

Returns a value of status.

See also

IntStatus


proc ::apave::WindowStatus {w name {val {}} {defval {}}} { # Sets/gets a status of window. The status is a value assigned to a name. # w - window's path # name - name of status # val - if blank, to get a value of status; otherwise a value to set # defval - default value (actual if the status not set beforehand) # Returns a value of status. # See also: IntStatus variable _AP_VARS if {$val eq {}} { ;# getting if {[info exist _AP_VARS($w,$name)]} { return $_AP_VARS($w,$name) } return $defval } return [set _AP_VARS($w,$name) $val] ;# setting }




writeTextFile [::apave]apave, Top

Writes to a text file.

writeTextFile fileName ?varName? ?doErr? ?doSave?
Parameters
fileNamefile name
varNamevariable name for file content or "" optional, default ""
doErrif 'true', exit at errors with error message; optional, default 0
doSaveif 'true', saves an empty file, else deletes it; optional, default 1
Return value

Returns "yes" if the file was saved successfully.


proc ::apave::writeTextFile {fileName {varName {}} {doErr 0} {doSave 1}} { # Writes to a text file. # fileName - file name # varName - variable name for file content or "" # doErr - if 'true', exit at errors with error message # doSave - if 'true', saves an empty file, else deletes it # # Returns "yes" if the file was saved successfully. variable _PU_opts if {$varName ne {}} { upvar $varName contents } else { set contents {} } set res yes if {!$doSave && [string trim $contents] eq {}} { if {[catch {file delete $fileName} _PU_opts(_ERROR_)]} { set res no } else { logMessage "delete $fileName" } } elseif {[catch {set chan [open $fileName w]} _PU_opts(_ERROR_)]} { set res no } else { ::apave::textChanConfigure $chan puts -nonewline $chan $contents close $chan logMessage "write $fileName" } if {!$res && $doErr} {error [::apave::error $fileName]} return $res }


Classesapave, Top



APave [::apave]apave, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
apaveThemeSee ObjectTheming.apaveTheme
basicDefFontSee ObjectTheming.basicDefFont
basicFontSizeSee ObjectTheming.basicFontSize
basicSmallFontSee ObjectTheming.basicSmallFont
basicTextFontSee ObjectTheming.basicTextFont
boldDefFontSee ObjectTheming.boldDefFont
boldTextFontSee ObjectTheming.boldTextFont
checkTimeoutButtonChecks if the timeout button is alive & focused; if not, cancels the timeout.
checkXYChecks the coordinates of window (against the screen).
chooserChooser (for all available types).
colorChooserColor chooser.
colorWindowInitialize colors of a window.
configureConfigures the apave object (all of _pav array may be changed).
create_FontsSee ObjectTheming.create_Fonts
create_FontsTypeSee ObjectTheming.create_FontsType
csAddSee ObjectTheming.csAdd
csCurrentSee ObjectTheming.csCurrent
csDarkSee ObjectTheming.csDark
csDeleteExternalSee ObjectTheming.csDeleteExternal
csExportSee ObjectTheming.csExport
csFontSee ObjectTheming.csFont
csFontDefSee ObjectTheming.csFontDef
csFontMonoSee ObjectTheming.csFontMono
csGetSee ObjectTheming.csGet
csGetNameSee ObjectTheming.csGetName
csMainColorsSee ObjectTheming.csMainColors
csMapThemeSee ObjectTheming.csMapTheme
csSetSee ObjectTheming.csSet
csTonedSee ObjectTheming.csToned
dateChooserDate chooser (calendar widget).
defaultAttrsSets or gets default grid options and attributes for widget type.
displayTaggedTextSets the text widget's contents using tags (ornamental details).
displayTextSets the text widget's contents.
fillGutterFills a gutter of text with the text's line numbers.
findWidPathSearches a widget's path among the active widgets.
focusNextSets focus on a next widget (possibly, defined as my Widget).
fontChooserFont chooser.
getPropertySee ObjectProperty.getProperty
getTextContentGets text content.
getWidChildrenGets children of a widget.
iconAGets icon attributes for buttons, menus etc.
initLinkFontGets/sets font attributes of links (labels & text tags with -link).
initTooltipSee ObjectTheming.initTooltip
labelFlashingOptions of 'flashing' label: -file (or -data) {list of image files (or data variables)} -label {list of labels' texts} -incr {increment for -alpha option} -pause {pause in seconds for -alpha 1.0} -after {interval for 'after'} -squeeze {value for *-big.png}
leadingSpacesReturns a number of leading spaces of a line
makeLabelLinkedMakes the linked label from a label.
makePopupMakes a popup menu for an editable widget.
makeWindowCreates a toplevel window that has to be paved.
onKeyTextMProcesses indents and braces at pressing keys.
optionCascadeTextRids a tk_optionCascade item of braces.
ownWNameGets a tail (last part) of widget's name
parentWNameGets parent name of widget.
paveoptionValueGets an option's value.
paveWindowProcesses "win / list_of_widgets" pairs.
readonlyWidgetSwitches on/off a widget's readonly state for a text widget.
resGets/sets a variable for vwait command.
resetTextResets a text widget to edit/view from scratch.
scrolledFrameNot documented.
setPropertySee ObjectProperty.setProperty
setTextBindsReturns bindings for a text widget.
showModalShows a window as modal.
showWindowDisplays a windows and goes in tkwait cycle to interact with a user.
textLinkGets a label's path of a link in a text widget.
themeExternalSee ObjectTheming.themeExternal
themeMandatorySee ObjectTheming.themeMandatory
themeNonThemedSee ObjectTheming.themeNonThemed
themePopupApplies a color scheme to a popup menu.
themeWindowSee ObjectTheming.themeWindow
timeoutButtonInvokes a button's action after a timeout.
tk_optionCascadeA bit modified tk_optionCascade widget made by Richard Suchenwirth.
untouchWidgetsSee ObjectTheming.untouchWidgets
validateColorChoiceDisplays a current color of color chooser's entry.
widgetTypeGets the widget type based on 3 initial letters of its name. Also fills the grid/pack options and attributes of the widget.
windowObsolete version of paveWindow (remains for compatibility).
Mixins

ObjectTheming

Subclasses

APaveDialog



constructor [::apave::APave]APave, Top

Creates APave object.

APave create ?cs? ?args?
Parameters
cscolor scheme (CS); optional, default -2
argsadditional arguments
Description

If cs>-2, the appropriate CS is set for the created APave object.

Fills _pav array with initial values.

Makes few procedures in the object's namespace to access from event handlers:

  • ListboxHandle
  • ListboxSelect
  • WinResize

This trick with proc inside an object is discussed at proc-in-tcl-ooclass


method constructor {{cs -2} args} { # Creates APave object. # cs - color scheme (CS) # args - additional arguments # # If cs>-2, the appropriate CS is set for the created APave object. # # Fills *_pav* array with initial values. # # Makes few procedures in the object's namespace to access from # event handlers: # - ListboxHandle # - ListboxSelect # - WinResize # This trick with *proc* inside an object is discussed at # [proc-in-tcl-ooclass](https://stackoverflow.com/questions/54804964/proc-in-tcl-ooclass) # keep the 'important' data of Pave object in array array set _pav [list] set _pav(ns) [namespace current]:: set _pav(lwidgets) [list] set _pav(moveall) 0 set _pav(tonemoves) 1 set _pav(initialcolor) {} set _pav(modalwin) {.} set _pav(fgbut) [ttk::style lookup TButton -foreground] set _pav(bgbut) [ttk::style lookup TButton -background] set _pav(fgtxt) [ttk::style lookup TEntry -foreground] set _pav(prepost) [list] set _pav(widgetopts) [list] set _pav(edge) {@@} if {$_pav(fgtxt) in {black #000000}} { set _pav(bgtxt) white } else { set _pav(bgtxt) [ttk::style lookup TEntry -background] } # namespace in object namespace for safety of its 'most important' data namespace eval ${_pav(ns)}PN {} array set ${_pav(ns)}PN::AR {} # set/reset a color scheme if it is/was requested if {$cs>=-1} {my csSet $cs} {my initTooltip} # object's procedures proc ListboxHandle {W offset maxChars} { set list {} foreach index [$W curselection] { lappend list [$W get $index] } set text [join $list \n] return [string range $text $offset [expr {$offset+$maxChars-1}]] } proc ListboxSelect {W} { # This code had been taken from Tcl's wiki: # https://wiki.tcl-lang.org/page/listbox+selection selection clear -displayof $W selection own -command {} $W selection handle -type UTF8_STRING $W [list [namespace current]::ListboxHandle $W] selection handle $W [list [namespace current]::ListboxHandle $W] return } proc WinResize {win} { # Restricts the window's sizes (thus fixing Tk's issue with a menubar) # win - path to a window to be of restricted sizes if {[lindex [$win configure -menu] 4] ne {}} { lassign [split [wm geometry $win] x+] w y lassign [wm minsize $win] wmin ymin if {$w<$wmin && $y<$ymin} { set corrgeom ${wmin}x${ymin} } elseif {$w<$wmin} { set corrgeom ${wmin}x${y} } elseif {$y<$ymin} { set corrgeom ${w}x${ymin} } else { return } wm geometry $win $corrgeom } return } # the end of APave constructor if {[llength [self next]]} { next {*}$args } return }



destructor [::apave::APave]APave, Top

Clears variables used in the object.

OBJECT destroy

method destructor {} { # Clears variables used in the object. array unset ${_pav(ns)}PN::AR namespace delete ${_pav(ns)}PN array unset _pav if {[llength [self next]]} next }



checkTimeoutButton [::apave::APave]APave, Top

Checks if the timeout button is alive & focused; if not, cancels the timeout.

OBJECT checkTimeoutButton w tmo lbl ?lbltext?
Parameters
wbutton's path
tmotimeout in sec.
lbllabel widget, where seconds to wait are displayed
lbltextoriginal text of label; optional, default ""

method checkTimeoutButton {w tmo lbl {lbltext {}}} { # Checks if the timeout button is alive & focused; if not, cancels the timeout. # w - button's path # tmo - timeout in sec. # lbl - label widget, where seconds to wait are displayed # lbltext - original text of label if {[winfo exists $lbl]} { if {[focus] in [list $w {}]} { if {$w in $::apave::_AP_VARS(TIMW)} { my timeoutButton $w $tmo $lbl $lbltext } } else { $lbl configure -text $lbltext } } }



checkXY [::apave::APave]APave, Top

Checks the coordinates of window (against the screen).

OBJECT checkXY w h x y
Parameters
wwidth of window
hheight of window
xwindow's X coordinate
ywindow's Y coordinate
Return value

Returns new coordinates in +X+Y form.


method checkXY {w h x y} { # Checks the coordinates of window (against the screen). # w - width of window # h - height of window # x - window's X coordinate # y - window's Y coordinate # Returns new coordinates in +X+Y form. # check for left/right edge of screen (accounting decors) set scrw [expr [winfo screenwidth .] - 12] set scrh [expr {[winfo screenheight .] - 36}] if {($x + $w) > $scrw } { set x [expr {$scrw - $w}] } if {($y + $h) > $scrh } { set y [expr {$scrh - $h}] } return +$x+$y }



chooser [::apave::APave]APave, Top

Chooser (for all available types).

OBJECT chooser nchooser tvar ?args?
Parameters
nchoosername of chooser
tvarname of variable containing an input/output value
argsoptions of the chooser
Description

The chooser names are:

tk_getOpenFilechoose a file to open
tk_getSaveFilechoose a file to save
tk_chooseDirectorychoose a directory
fontChooserchoose a font
dateChooserchoose a date
colorChooserchoose a color
ftx_OpenFile(internal) choose a file for ftx widget
Return value

Returns a selected value.


method chooser {nchooser tvar args} { # Chooser (for all available types). # nchooser - name of chooser # tvar - name of variable containing an input/output value # args - options of the chooser # # The chooser names are: # tk_getOpenFile - choose a file to open # tk_getSaveFile - choose a file to save # tk_chooseDirectory - choose a directory # fontChooser - choose a font # dateChooser - choose a date # colorChooser - choose a color # ftx_OpenFile - (internal) choose a file for ftx widget # # Returns a selected value. set isfilename 0 lassign [::apave::extractOptions args -ftxvar {} -tname {}] ftxvar tname lassign [::apave::getProperty DirFilGeoVars] dirvar filvar set vargeo [set dirgeo [set filgeo {}]] set parent [my ParentOpt] if {$dirvar ne {}} {set dirgeo [set $dirvar]} if {$filvar ne {}} {set filgeo [set $filvar]} if {$nchooser eq {ftx_OpenFile}} { set nchooser tk_getOpenFile } set widname {} set choosname $nchooser if {$choosname in {"fontChooser" "colorChooser" "dateChooser"}} { set nchooser "my $choosname $tvar" } elseif {$choosname in {tk_getOpenFile tk_getSaveFile}} { set vargeo $filvar set widname [my AuxSetChooserGeometry $vargeo $dirvar $parent __tk_filedialog] if {[set fn [set $tvar]] eq {}} { set dn [pwd] } else { set dn [file dirname $fn] set fn [file tail $fn] } set dn [::apave::extractOptions args -initialdir $dn] set args "-initialfile \"$fn\" -initialdir \"$dn\" $parent $args" incr isfilename } elseif {$nchooser eq {tk_chooseDirectory}} { set vargeo $dirvar set widname [my AuxSetChooserGeometry $vargeo $filvar $parent __tk_choosedir] set args "-initialdir \"[set $tvar]\" $parent $args" incr isfilename } if {$::tcl_platform(platform) eq {unix} && $choosname ne {dateChooser}} { my themeExternal *.foc.* *f1.demo ;# don't touch tkcc's boxes } set res [{*}$nchooser {*}$args] if {"$res" ne {} && "$tvar" ne {}} { if {$isfilename} { lassign [my SplitContentVariable $ftxvar] -> txtnam wid if {[info exist $ftxvar] && [file exist [set res [file nativename $res]]]} { set $ftxvar [::apave::readTextFile $res] if {[winfo exist $txtnam]} { my readonlyWidget $txtnam no my displayTaggedText $txtnam $ftxvar my readonlyWidget $txtnam yes set wid [string range $txtnam 0 [string last . $txtnam]]$wid $wid configure -text "$res" ::tk::TextSetCursor $txtnam 1.0 update } } } set $tvar $res } if {$vargeo ne {} && $widname ne {} && [::islinux]} { catch { set $vargeo [list $widname [wm geometry $widname]] ;# 1st item for possible usage only } } if {$tname ne {}} { set tname [my [my ownWName $tname]] focus $tname after idle [$tname selection range 0 end] } return $res }



colorChooser [::apave::APave]APave, Top

Color chooser.

OBJECT colorChooser tvar ?args?
Parameters
tvarname of variable containing a color
argsoptions of tk_chooseColor
Description

The tvar sets the value of -initialcolor option. Also it gets a color selected in the chooser.

Return value

Returns a selected color.


method colorChooser {tvar args} { # Color chooser. # tvar - name of variable containing a color # args - options of *tk_chooseColor* # # The *tvar* sets the value of *-initialcolor* option. Also # it gets a color selected in the chooser. # # Returns a selected color. if {$_pav(initialcolor) eq {} && $::tcl_platform(platform) eq {unix}} { source [file join $::apave::apaveDir pickers color clrpick.tcl] } if {[set _ [string trim [set $tvar]]] ne {}} { set ic $_ set _ [. cget -background] if {[catch {. configure -background $ic}]} { set ic "#$ic" if {[catch {. configure -background $ic}]} {set ic black} } set _pav(initialcolor) $ic . configure -background $_ } else { set _pav(initialcolor) black } if {[catch {lassign [tk_chooseColor -moveall $_pav(moveall) -tonemoves $_pav(tonemoves) -initialcolor $_pav(initialcolor) {*}$args] res _pav(moveall) _pav(tonemoves)}]} { set args [::apave::removeOptions $args -moveall -tonemoves] set res [tk_chooseColor -initialcolor $_pav(initialcolor) {*}$args] } if {$res ne {}} { set _pav(initialcolor) [set $tvar $res] } return $res }



colorWindow [::apave::APave]APave, Top

Initialize colors of a window.

OBJECT colorWindow win
Parameters
winwindow's path

method colorWindow {win} { # Initialize colors of a window. # win - window's path if {[my apaveTheme]} { my csSet [my csCurrent] $win -doit } else { my themeNonThemed $win } }



configure [::apave::APave]APave, Top

Configures the apave object (all of _pav array may be changed).

OBJECT configure ?args?
Parameters
argslist of pairs name/value of options
Description

Example:


pobj configure edge "@@"

method configure {args} { # Configures the apave object (all of *_pav* array may be changed). # args - list of pairs name/value of options # Example: # pobj configure edge "@@" foreach {optnam optval} $args { set _pav($optnam) $optval } return }



dateChooser [::apave::APave]APave, Top

Date chooser (calendar widget).

OBJECT dateChooser tvar ?args?
Parameters
tvarname of variable containing a date
argsoptions of ::klnd::calendar
Return value

Returns a selected date.


method dateChooser {tvar args} { # Date chooser (calendar widget). # tvar - name of variable containing a date # args - options of *::klnd::calendar* # # Returns a selected date. my SourceKlnd {} if {![catch {set ent [my [my ownWName [::apave::getOption -entry {*}$args]]]}]} { dict set args -entry $ent set res [::klnd::calendar {*}$args -tvar $tvar -parent [winfo toplevel $ent]] } else { set res [::klnd::calendar {*}$args -tvar $tvar] } return $res }



defaultAttrs [::apave::APave]APave, Top

Sets or gets default grid options and attributes for widget type.

OBJECT defaultAttrs ?typ? ?opt? ?atr?
Parameters
typwidget type; optional, default ""
optnew default grid options; optional, default ""
atrnew default attributes; optional, default ""
Description

Returns:

  • if not set typ: a full list of options and attributes of all types
  • if set 'typ' only: a list of options and attributes of 'typ'
  • else: a list of updated options and attributes of the widget type

method defaultAttrs {{typ {}} {opt {}} {atr {}}} { # Sets or gets default grid options and attributes for widget type. # typ - widget type # opt - new default grid options # atr - new default attributes # Returns: # - if not set typ: a full list of options and attributes of all types # - if set 'typ' only: a list of options and attributes of 'typ' # - else: a list of updated options and attributes of the widget type if {$typ eq {}} {return $::apave::_Defaults} set def1 [subst [dict get $::apave::_Defaults $typ]] if {"$opt$atr" eq {}} {return $def1} lassign $def1 defopts defattrs set newval [list "$defopts $opt" "$defattrs $atr"] dict set ::apave::_Defaults $typ $newval return $newval }



displayTaggedText [::apave::APave]APave, Top

Sets the text widget's contents using tags (ornamental details).

OBJECT displayTaggedText w contsName ?tags?
Parameters
wtext widget's name
contsNamevariable name for contents to be set in the widget
tagslist of tags to be applied to the text; optional, default ""
Description

The lines in text contents are divided by \n and can include tags like in a html layout, e.g. RED ARMY.

The tags is a list of "name/value" pairs. 1st is a tag's name, 2nd is a tag's value.

The tag's name is "pure" one (without <>) so e.g.for .. the tag list contains "b".

The tag's value is a string of text attributes (-font etc.).


method displayTaggedText {w contsName {tags {}}} { # Sets the text widget's contents using tags (ornamental details). # w - text widget's name # contsName - variable name for contents to be set in the widget # tags - list of tags to be applied to the text # # The lines in *text contents* are divided by \n and can include # *tags* like in a html layout, e.g. <red>RED ARMY</red>. # # The *tags* is a list of "name/value" pairs. 1st is a tag's name, 2nd # is a tag's value. # # The tag's name is "pure" one (without <>) so e.g.for <b>..</b> the tag # list contains "b". # # The tag's value is a string of text attributes (-font etc.). upvar $contsName conts if {$tags eq {}} { my displayText $w $conts return } if { [set state [$w cget -state]] ne {normal}} { $w configure -state normal } set taglist [set tagpos [set taglen [list]]] foreach tagi $tags { lassign $tagi tag opts if {![string match link* $tag]} { $w tag config $tag {*}$opts } lappend tagpos 0 lappend taglen [string length $tag] } set tLen [llength $tags] set disptext {} set irow 1 foreach line [split $conts \n] { if {$irow > 1} { append disptext \n } set newline {} while 1 { set p [string first \< $line] if {$p < 0} { break } append newline [string range $line 0 $p-1] set line [string range $line $p end] set i 0 set nrnc $irow.[string length $newline] foreach tagi $tags pos $tagpos len $taglen { lassign $tagi tag if {[string first <$tag> $line]==0} { if {$pos ne {0}} { error "\napaveme.tcl: mismatched <$tag> in line $irow.\n" } lset tagpos $i $nrnc set line [string range $line $len+2 end] break } elseif {[string first </$tag> $line]==0} { if {$pos eq {0}} { error "\napaveme.tcl: mismatched </$tag> in line $irow.\n" } lappend taglist [list $i $pos $nrnc] lset tagpos $i 0 set line [string range $line $len+3 end] break } incr i } if {$i == $tLen} { # tag not found after "<" - shift by 1 character append newline [string index $line 0] set line [string range $line 1 end] } } append disptext $newline $line incr irow } $w replace 1.0 end $disptext lassign [my csGet] fg fg2 bg bg2 set lfont [$w cget -font] catch {set lfont [font actual $lfont]} foreach {o v} [my initLinkFont] {dict set lfont $o $v} set ::apave::__TEXTLINKS__($w) [list] for {set it [llength $taglist]} {[incr it -1]>=0} {} { set tagli [lindex $taglist $it] lassign $tagli i p1 p2 lassign [lindex $tags $i] tag opts if {[string match link* $tag] && [set ist [lsearch -exact -index 0 $tags $tag]]>=0} { set txt [$w get $p1 $p2] set lab ${w}l[incr ::apave::__linklab__] ttk::label $lab -text $txt -font $lfont -foreground $fg -background $bg set ::apave::__TEXTLINKS__($w) [linsert $::apave::__TEXTLINKS__($w) 0 $lab] $w delete $p1 $p2 $w window create $p1 -window $lab set v [lindex $tags $ist 1] my makeLabelLinked $lab $v $fg $bg $fg2 $bg2 } else { $w tag add $tag $p1 $p2 } } my resetText $w $state return }



displayText [::apave::APave]APave, Top

Sets the text widget's contents.

OBJECT displayText w conts ?pos?
Parameters
wtext widget's name
contscontents to be set in the widget
posNot documented; optional, default 1.0

method displayText {w conts {pos 1.0}} { # Sets the text widget's contents. # w - text widget's name # conts - contents to be set in the widget if {[set state [$w cget -state]] ne {normal}} { $w configure -state normal } $w replace 1.0 end $conts $w edit reset; $w edit modified no if {$state eq {normal}} { ::tk::TextSetCursor $w $pos } else { $w configure -state $state } return }



fillGutter [::apave::APave]APave, Top

Fills a gutter of text with the text's line numbers.

OBJECT fillGutter txt ?canvas? ?width? ?shift? ?args?
Parameters
txtpath to the text widget
canvascanvas of the gutter; optional, default ""
widthwidth of the gutter, in chars; optional, default ""
shiftaddition to the width (to shift from the left side); optional, default ""
argsadditional arguments for tracing
Description

The code is borrowed from open source tedit project.


method fillGutter {txt {canvas {}} {width {}} {shift {}} args} { # Fills a gutter of text with the text's line numbers. # txt - path to the text widget # canvas - canvas of the gutter # width - width of the gutter, in chars # shift - addition to the width (to shift from the left side) # args - additional arguments for tracing # The code is borrowed from open source tedit project. if {![winfo exists $txt] || ![winfo ismapped $txt]} return if {$canvas eq {}} { event generate $txt <Configure> ;# repaints the gutter return } set oper [lindex $args 0 1] if {![llength $args] || [lindex $args 0 4] eq {-elide} || $oper in {configure delete insert see yview}} { set i [$txt index @0,0] set gcont [list] while true { set dline [$txt dlineinfo $i] if {[llength $dline] == 0} break set height [lindex $dline 3] set y [expr {[lindex $dline 1]}] set linenum [format "%${width}d" [lindex [split $i .] 0]] set i [$txt index "$i +1 lines linestart"] lappend gcont [list $y $linenum] } # update the gutter at changing its contents/config if {[::apave::cs_Active]} { lassign [my csGet] - - - bg - - - - fg ::apave::setProperty _GUTTER_FGBG [list $fg $bg] } else { lassign [::apave::getProperty _GUTTER_FGBG] fg bg } set cwidth [expr {$shift + [font measure apaveFontMono -displayof $txt [string repeat 0 $width]]}] set newbg [expr {$bg ne [$canvas cget -background]}] set newwidth [expr {$cwidth ne [$canvas cget -width]}] set savedcont [namespace current]::gc$txt if {![llength $args] || $newbg || $newwidth || ![info exists $savedcont] || $gcont ne [set $savedcont]} { if {$newbg} {$canvas config -background $bg} if {$newwidth} {$canvas config -width $cwidth} $canvas delete all foreach g $gcont { lassign $g y linenum $canvas create text 2 $y -anchor nw -text $linenum -font apaveFontMono -fill $fg } set $savedcont $gcont } } }



findWidPath [::apave::APave]APave, Top

Searches a widget's path among the active widgets.

OBJECT findWidPath wid ?mode? ?visible?
Parameters
widNot documented.
modeif "exact", searches .wid; if "globe", searches wid*; optional, default exact
visibleNot documented; optional, default yes
wwidget name, set partially e.g. "wid" instead of ".win.wid"
Return value

Returns the widget's full path or "" if the widget isn't active.


method findWidPath {wid {mode exact} {visible yes}} { # Searches a widget's path among the active widgets. # w - widget name, set partially e.g. "wid" instead of ".win.wid" # mode - if "exact", searches *.wid; if "globe", searches *wid* # Returns the widget's full path or "" if the widget isn't active. my getWidChildren . tree if {$mode eq {exact}} { set i [lsearch -glob $tree "*.$wid"] } else { set i [lsearch -glob $tree "*$wid*"] } if {$i>-1} {return [lindex $tree $i]} return {} }



focusNext [::apave::APave]APave, Top

Sets focus on a next widget (possibly, defined as my Widget).

OBJECT focusNext w wnext ?wnext0?
Parameters
wparent window name
wnextnext widget's name
wnext0core next name (used internally, for recursive search); optional, default ""

method focusNext {w wnext {wnext0 {}}} { # Sets focus on a next widget (possibly, defined as `my Widget`). # w - parent window name # wnext - next widget's name # wnext0 - core next name (used internally, for recursive search) if {$wnext eq {}} return if {[winfo exist $wnext]} { focus $wnext ;# direct path to the next widget return } # try to find the next widget in hierarchy of widgets set ws $wnext if {$wnext0 eq {}} { # get the real next widget (wnext can be uppercased or calculated) catch {set wnext [subst $wnext]} if {![string match {my *} $wnext]} { catch {set wnext [my [my ownWName $wnext]]} } my focusNext $w $wnext $wnext } else { set wnext $wnext0 } foreach wn [winfo children $w] { my focusNext $wn $wnext $wnext0 if {[string match "*.$wnext" $wn] || [string match "*.$ws" $wn]} { focus $wn return } } return }



fontChooser [::apave::APave]APave, Top

Font chooser.

OBJECT fontChooser tvar ?args?
Parameters
tvarname of variable containing a font
argsoptions of tk fontchooser
Description

The tvar sets the value of -font option. Also it gets a font selected in the chooser.

Return value

Returns a selected font.


method fontChooser {tvar args} { # Font chooser. # tvar - name of variable containing a font # args - options of *tk fontchooser* # # The *tvar* sets the value of *-font* option. Also # it gets a font selected in the chooser. # # Returns a selected font. proc [namespace current]::applyFont {font} " set $tvar \[font actual \$font\]" set font [set $tvar] if {$font eq {}} { catch {font create fontchoose {*}$::apave::FONTMAIN} } else { catch {font delete fontchoose} catch {font create fontchoose {*}[font actual $font]} } tk fontchooser configure -parent . -font fontchoose {*}[my ParentOpt] {*}$args -command [namespace current]::applyFont set res [tk fontchooser show] return [set $tvar] ;#$font }



getTextContent [::apave::APave]APave, Top

Gets text content.

OBJECT getTextContent tvar
Parameters
tvartext variable
Description

Uses an internal text variable to extract the text contents.

Return value

Returns the content of text.


method getTextContent {tvar} { # Gets text content. # tvar - text variable # Uses an internal text variable to extract the text contents. # Returns the content of text. lassign [my SplitContentVariable [my GetContentVariable $tvar]] -> txtnam wid return [string trimright [$txtnam get 1.0 end]] }



getWidChildren [::apave::APave]APave, Top

Gets children of a widget.

OBJECT getWidChildren wid treeName ?init?
Parameters
widwidget's path
treeNamename of variable to hold the result.
initNot documented; optional, default yes

method getWidChildren {wid treeName {init yes}} { # Gets children of a widget. # wid - widget's path # treeName - name of variable to hold the result. upvar $treeName tree if {$init} {set tree [list]} foreach ch [winfo children $wid] { lappend tree $ch my getWidChildren $ch $treeName no } }



iconA [::apave::APave]APave, Top

Gets icon attributes for buttons, menus etc.

OBJECT iconA icon ?iconset?
Parameters
iconname of icon
iconsetone of small/middle/large; optional, default small
Description

The iconset is "small" for menus (recommended and default).


method iconA {icon {iconset small}} { # Gets icon attributes for buttons, menus etc. # icon - name of icon # iconset - one of small/middle/large # The *iconset* is "small" for menus (recommended and default). return "-image [::apave::iconImage $icon $iconset] -compound left" }



initLinkFont [::apave::APave]APave, Top

Gets/sets font attributes of links (labels & text tags with -link).

OBJECT initLinkFont ?args?
Parameters
argsfont attributes ("-underline 1" by default)
Return value

Returns the current value of these attributes.


method initLinkFont {args} { # Gets/sets font attributes of links (labels & text tags with -link). # args - font attributes ("-underline 1" by default) # Returns the current value of these attributes. if {[set ll [llength $args]]} { if {$ll%2} { ;# clear the attributes, if called with "" set ::apave::_AP_VARS(LINKFONT) [list] } else { set ::apave::_AP_VARS(LINKFONT) $args } } return $::apave::_AP_VARS(LINKFONT) }



labelFlashing [::apave::APave]APave, Top

Options of 'flashing' label: -file (or -data) {list of image files (or data variables)} -label {list of labels' texts} -incr {increment for -alpha option} -pause {pause in seconds for -alpha 1.0} -after {interval for 'after'} -squeeze {value for *-big.png}

OBJECT labelFlashing w1 w2 first ?args?
Parameters
w1Not documented.
w2Not documented.
firstNot documented.
argsOptional arguments.

method labelFlashing {w1 w2 first args} { # Options of 'flashing' label: # -file (or -data) {list of image files (or data variables)} # -label {list of labels' texts} # -incr {increment for -alpha option} # -pause {pause in seconds for -alpha 1.0} # -after {interval for 'after'} # -squeeze {value for *-big.png} if {![winfo exists $w1]} return if {$first} { lassign [::apave::parseOptions $args -file {} -data {} -label {} -incr 0.01 -pause 3.0 -after 10 -squeeze {} -static 0] ofile odata olabel oincr opause oafter osqueeze ostatic if {$osqueeze ne {}} {set osqueeze "-subsample $osqueeze"} lassign {0 -2 0 1} idx incev waitev direv } else { lassign $args ofile odata olabel oincr opause oafter osqueeze ostatic idx incev waitev direv } set llf [llength $ofile] set lld [llength $odata] if {[set llen [expr {max($llf,$lld)}]]==0} return incr incev $direv set alphaev [expr {$oincr*$incev}] if {$alphaev>=1} { set alpha 1.0 if {[incr waitev -1]<0} { set direv -1 } } elseif {$alphaev<0} { set alpha 0.0 set idx [expr {$idx%$llen+1}] set direv 1 set incev 0 set waitev [expr {int($opause/$oincr)}] } else { set alpha $alphaev } if {$llf} { set png [list -file [lindex $ofile $idx-1]] } elseif {[info exists [set datavar [lindex $odata $idx-1]]]} { set png [list -data [set $datavar]] } else { set png [list -data $odata] } set NS [namespace current] if {$ostatic} { image create photo ${NS}::ImgT$w1 {*}$png $w1 configure -image ${NS}::ImgT$w1 } else { image create photo ${NS}::ImgT$w1 {*}$png -format "png -alpha $alpha" image create photo ${NS}::Img$w1 ${NS}::Img$w1 copy ${NS}::ImgT$w1 {*}$osqueeze $w1 configure -image ${NS}::Img$w1 } if {$w2 ne {}} { if {$alphaev<0.33 && !$ostatic} { set fg [$w1 cget -background] } else { if {[info exists ::apave::_AP_VISITED(FG,$w2)]} { set fg $::apave::_AP_VISITED(FG,$w2) } else { set fg [$w1 cget -foreground] } } $w2 configure -text [lindex $olabel $idx-1] -foreground $fg } after $oafter [list [self] labelFlashing $w1 $w2 0 $ofile $odata $olabel $oincr $opause $oafter $osqueeze $ostatic $idx $incev $waitev $direv] }



leadingSpaces [::apave::APave]APave, Top

Returns a number of leading spaces of a line

OBJECT leadingSpaces line
Parameters
linethe line
Return value

Returns a number of leading spaces of a line


method leadingSpaces {line} { # Returns a number of leading spaces of a line # line - the line return [expr {[string length $line]-[string length [string trimleft $line]]}] }



makeLabelLinked [::apave::APave]APave, Top

Makes the linked label from a label.

OBJECT makeLabelLinked lab v fg bg fg2 bg2 ?doadd? ?inv?
Parameters
lablabel's path
vdata of the link: command, tip, visited
fgforeground unhovered
bgbackground unhovered
fg2foreground hovered
bg2background hovered
doaddflag "register the label in the list of visited" optional, default yes
invflag "invert the meaning of colors" optional, default no

method makeLabelLinked {lab v fg bg fg2 bg2 {doadd yes} {inv no}} { # Makes the linked label from a label. # lab - label's path # v - data of the link: command, tip, visited # fg - foreground unhovered # bg - background unhovered # fg2 - foreground hovered # bg2 - background hovered # doadd - flag "register the label in the list of visited" # inv - flag "invert the meaning of colors" set txt [$lab cget -text] 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 {}} { set tt [my MC $tt] ::baltip tip $lab $tt lappend ::apave::_AP_VARS(TIMW) $lab } if {$inv} { set ft $fg set bt $bg set fg $fg2 set bg $bg2 set fg2 $ft set bg2 $bt } my VisitedLab $lab $v $vz $fg $bg bind $lab <Enter> "::apave::obj EXPORT HoverLab $lab {$v} yes $fg2 $bg2" bind $lab <Leave> "::apave::obj EXPORT HoverLab $lab {$v} no $fg $bg" bind $lab <Button-1> "::apave::obj EXPORT VisitedLab $lab {$v} yes $fg2 $bg2;$v" if {$doadd} {lappend ::apave::_AP_VISITED(ALL) [list $lab $v $inv]} return [list $fg $bg $fg2 $bg2] }



makePopup [::apave::APave]APave, Top

Makes a popup menu for an editable widget.

OBJECT makePopup w ?isRO? ?istext? ?tearoff? ?addpop?
Parameters
wwidget's name
isROflag for "is it readonly" optional, default no
istextflag for "is it a text" optional, default no
tearoffflag for "-tearoff" option; optional, default no
addpopadditional commands for popup menu; optional, default ""

method makePopup {w {isRO no} {istext no} {tearoff no} {addpop {}}} { # Makes a popup menu for an editable widget. # w - widget's name # isRO - flag for "is it readonly" # istext - flag for "is it a text" # tearoff - flag for "-tearoff" option # addpop - additional commands for popup menu set pop $w.popupMenu catch {menu $pop -tearoff $tearoff} $pop delete 0 end if {$isRO} { $pop add command {*}[my iconA copy] -accelerator Ctrl+C -label Copy -command "event generate $w <<Copy>>" if {$istext} { eval [my popupHighlightCommands $pop $w] after idle [list [self] set_highlight_matches $w] } } else { if {$istext} { $pop add command {*}[my iconA cut] -accelerator Ctrl+X -label Cut -command "::apave::eventOnText $w <<Cut>>" $pop add command {*}[my iconA copy] -accelerator Ctrl+C -label Copy -command "::apave::eventOnText $w <<Copy>>" $pop add command {*}[my iconA paste] -accelerator Ctrl+V -label Paste -command "::apave::eventOnText $w <<Paste>>" $pop add separator $pop add command {*}[my iconA undo] -accelerator Ctrl+Z -label Undo -command "::apave::eventOnText $w <<Undo>>" $pop add command {*}[my iconA redo] -accelerator Ctrl+Shift+Z -label Redo -command "::apave::eventOnText $w <<Redo>>" eval [my popupBlockCommands $pop $w] eval [my popupHighlightCommands $pop $w] if {$addpop ne {}} { lassign $addpop com par1 par2 eval [my $com $pop $w {*}$par1 {*}$par2] } after idle [list [self] set_highlight_matches $w] after idle [my setTextBinds $w] } else { $pop add command {*}[my iconA cut] -accelerator Ctrl+X -label Cut -command "event generate $w <<Cut>>" $pop add command {*}[my iconA copy] -accelerator Ctrl+C -label Copy -command "event generate $w <<Copy>>" $pop add command {*}[my iconA paste] -accelerator Ctrl+V -label Paste -command "event generate $w <<Paste>>" } } if {$istext} { $pop add separator $pop add command {*}[my iconA none] -accelerator Ctrl+A -label {Select All} -command "$w tag add sel 1.0 end" bind $w <Control-a> "$w tag add sel 1.0 end; break" } bind $w <Button-3> "[self] themePopup $w.popupMenu; tk_popup $w.popupMenu %X %Y" return }



makeWindow [::apave::APave]APave, Top

Creates a toplevel window that has to be paved.

OBJECT makeWindow w ttl ?args?
Parameters
wwindow's name
ttlwindow's title
argsoptions for 'toplevel' command
Description

If $w matches "*.fra" then ttk::frame is created with name $w.


method makeWindow {w ttl args} { # Creates a toplevel window that has to be paved. # w - window's name # ttl - window's title # args - options for 'toplevel' command # If $w matches "*.fra" then ttk::frame is created with name $w. my CleanUps set w [set wtop [string trimright $w .]] set withfr [expr {[set pp [string last . $w]]>0 && [string match *.fra $w]}] if {$withfr} { set wtop [string range $w 0 $pp-1] } catch {destroy $wtop} toplevel $wtop {*}$args if {[::iswindows]} { ;# maybe nice to hide all windows manipulations wm attributes $wtop -alpha 0.0 } else { wm withdraw $wtop } if {$withfr} { pack [ttk::frame $w] -expand 1 -fill both } wm title $wtop $ttl return $wtop }



onKeyTextM [::apave::APave]APave, Top

Processes indents and braces at pressing keys.

OBJECT onKeyTextM w K ?s?
Parameters
wtext's path
Kkey's name
skey's state; optional, default ""

method onKeyTextM {w K {s {}}} { # Processes indents and braces at pressing keys. # w - text's path # K - key's name # s - key's state set lindt [string length $::apave::_AP_VARS(INDENT)] switch -exact $K { Return - KP_Enter { # at pressing Enter key, indent (and possibly add the right brace) # but shift/ctrl+Enter acts by default - without indenting if {$s & 1 || $s & 4} return set idx1 [$w index {insert linestart}] set idx2 [$w index {insert lineend}] set line [$w get $idx1 $idx2] set nchars [my leadingSpaces $line] set indent [string range $line 0 $nchars-1] set ch1 [string range $line $nchars $nchars+1] set islist [expr {$ch1 in {{* } {- } {# }}}] set ch2 [string index $line end] set idx1 [$w index insert] set idx2 [$w index "$idx1 +1 line"] set st2 [$w get "$idx2 linestart" "$idx2 lineend"] set ch3 [string index [string trimleft $st2] 0] if {$indent ne {} || $ch2 eq "\{" || $K eq {KP_Enter} || $st2 ne {} || $islist} { set st1 [$w get "$idx1" "$idx1 lineend"] if {[string index $st1 0] in [list \t { }]} { # if space(s) are at the right, remove them at cutting set n1 [my leadingSpaces $st1] $w delete $idx1 [$w index "$idx1 +$n1 char"] } elseif {$ch2 eq "\{" && $st1 eq {}} { # indent + closing brace set nchars2 [my leadingSpaces $st2] if {$st2 eq {} || $nchars>$nchars2 || ($nchars==$nchars2 && $ch3 ne "\}")} { append indent $::apave::_AP_VARS(INDENT) \n $indent "\}" } else { append indent $::apave::_AP_VARS(INDENT) } incr nchars $lindt } elseif {$indent eq {} && $st2 ne {}} { # no indent of previous line, try to get it from the next if {[string trim $st2] eq "\}"} { # add indentation for the next brace set st2 "$::apave::_AP_VARS(INDENT)$st2" } set nchars [my leadingSpaces $st2] set indent [string range $st2 0 [expr {$nchars-1}]] } # a new line supplied with "list-like pattern" if {$islist && ![string match *.0 $idx1] && [string trim [$w get "$idx1 linestart" $idx1]] ne {}} { if {$ch1 eq {# } && int($idx1)>1} { # for comments: if only more than 1 of them, then add another set idx0 [$w index "$idx1 -1 line"] set st0 [string trimleft [$w get "$idx0 linestart" "$idx0 lineend"]] if {[string index $st0 0] ne {#} && $ch3 ne {#}} { set ch1 {} } } set indent "$indent$ch1" incr nchars [string length $ch1] } $w insert $idx1 \n$indent ::tk::TextSetCursor $w [$w index "$idx2 linestart +$nchars char"] return -code break } } braceright { # right brace pressed: if no other chars in the line, shift the brace set idx1 [$w index "insert"] set st [$w get "$idx1 linestart" "$idx1 lineend"] if {[string trim $st] eq {} && [string length $st]>=$lindt} { $w delete "$idx1 lineend -$lindt char" "$idx1 lineend" } } } }



optionCascadeText [::apave::APave]APave, Top

Rids a tk_optionCascade item of braces.

OBJECT optionCascadeText it
Parameters
itan item to be trimmed
Description

Reason: tk_optionCascade items shimmer between 'list' and 'string' so a multiline item is displayed with braces, if not got rid of them.

Return value

Returns the item trimmed.

See also

tk_optionCascade


method optionCascadeText {it} { # Rids a tk_optionCascade item of braces. # it - an item to be trimmed # # Reason: tk_optionCascade items shimmer between 'list' and 'string' # so a multiline item is displayed with braces, if not got rid of them. # # Returns the item trimmed. # # See also: tk_optionCascade if {[string match "\{*\}" $it]} { set it [string range $it 1 end-1] } return $it }



ownWName [::apave::APave]APave, Top

Gets a tail (last part) of widget's name

OBJECT ownWName name
Parameters
namename (path) of the widget

method ownWName {name} { # Gets a tail (last part) of widget's name # name - name (path) of the widget return [lindex [split $name .] end] }



parentWName [::apave::APave]APave, Top

Gets parent name of widget.

OBJECT parentWName name
Parameters
namename (path) of the widget

method parentWName {name} { # Gets parent name of widget. # name - name (path) of the widget return [string range $name 0 [string last . $name]-1] }



paveoptionValue [::apave::APave]APave, Top

Gets an option's value.

OBJECT paveoptionValue option
Parameters
optionoption's name
Return value

Returns a value from _pav array (for options like "moveall", "tonemoves").


method paveoptionValue {option} { # Gets an option's value. # option - option's name # Returns a value from _pav array (for options like "moveall", "tonemoves"). if {[info exists _pav($option)]} { return [set _pav($option)] } return {} }



paveWindow [::apave::APave]APave, Top

Processes "win / list_of_widgets" pairs.

OBJECT paveWindow ?args?
Parameters
argslist of pairs "win / lwidgets"
Description

The win is a window's path. The lwidgets is a list of widget items.

Each widget item contains:

namewidget's name (first 3 characters define its type)
neighbortop or left neighbor of the widget
posofneiposition of neighbor: T (top) or L (left)
rowspanrow span of the widget
colspancolumn span of the widget
optionsgrid/pack options
attrsattributes of widget

First 3 items are mandatory, others are set at need.

This method calls paveWindow in a cycle, to process a current "win / lwidgets" pair.


method paveWindow {args} { # Processes "win / list_of_widgets" pairs. # args - list of pairs "win / lwidgets" # # The *win* is a window's path. The *lwidgets* is a list of # widget items. # # Each widget item contains: # name - widget's name (first 3 characters define its type) # neighbor - top or left neighbor of the widget # posofnei - position of neighbor: T (top) or L (left) # rowspan - row span of the widget # colspan - column span of the widget # options - grid/pack options # attrs - attributes of widget # First 3 items are mandatory, others are set at need. # # This method calls *paveWindow* in a cycle, to process a current # "win / lwidgets" pair. set res [list] set wmain [set wdia {}] foreach {w lwidgets} $args { if {[lindex $lwidgets 0 0] eq {after}} { # if 1st item is "after idle" or like "after 1000", layout the window after... # (fit for "invisible independent" windows/frames/tabs) set what [lindex $lwidgets 0 1] if {$what eq {idle} || [string is integer -strict $what]} { after $what [list [self] paveWindow $w [lrange $lwidgets 1 end]] } continue } lappend res {*}[my Window $w $lwidgets] lappend _pav(lwidgets) $lwidgets ;# possibly useful if {[set ifnd [regexp -indices -inline {[.]dia\d+} $w]] ne {}} { set wdia [string range $w 0 [lindex $ifnd 0 1]] } else { set wmain .[lindex [split $w .] 1] } } # add a system Menu binding for the created window if {[winfo exists $wdia]} {::apave::initPOP $wdia} elseif { [winfo exists $wmain]} {::apave::initPOP $wmain} return $res }



readonlyWidget [::apave::APave]APave, Top

Switches on/off a widget's readonly state for a text widget.

OBJECT readonlyWidget w ?on? ?popup?
Parameters
wtext widget's path
on"on/off" boolean flag; optional, default yes
popup"make popup menu" boolean flag; optional, default yes
See also

wiki.tcl-lang.org


method readonlyWidget {w {on yes} {popup yes}} { # Switches on/off a widget's readonly state for a text widget. # w - text widget's path # on - "on/off" boolean flag # popup - "make popup menu" boolean flag # See also: # [wiki.tcl-lang.org](https://wiki.tcl-lang.org/page/Read-only+text+widget) my TextCommandForChange $w {} $on if {$popup} {my makePopup $w $on yes} return }



res [::apave::APave]APave, Top

Gets/sets a variable for vwait command.

OBJECT res win ?result?
Parameters
winwindow's path
resultvalue of variable; optional, default get
Description

This method is used when

  • an event cycle should be stopped with changing a variable's value
  • a result of event cycle (the variable's value) should be got

In the first case, result is set to an integer. In apave dialogs the integer is corresponding a pressed button's index.

In the second case, result is omitted or equal to "get".

Return value

Returns a value of variable that controls an event cycle.


method res {win {result get}} { # Gets/sets a variable for *vwait* command. # win - window's path # result - value of variable # # This method is used when # - an event cycle should be stopped with changing a variable's value # - a result of event cycle (the variable's value) should be got # # In the first case, *result* is set to an integer. In *apave* dialogs # the integer is corresponding a pressed button's index. # # In the second case, *result* is omitted or equal to "get". # # Returns a value of variable that controls an event cycle. if {$result eq {get}} { return [set ${_pav(ns)}PN::AR($win)] } my CleanUps $win return [set ${_pav(ns)}PN::AR($win) $result] }



resetText [::apave::APave]APave, Top

Resets a text widget to edit/view from scratch.

OBJECT resetText w state ?contsName?
Parameters
wtext widget's name
statewidget's final state (normal/disabled)
contsNamevariable name for contents to be set in the widget; optional, default ""

method resetText {w state {contsName {}}} { # Resets a text widget to edit/view from scratch. # w - text widget's name # state - widget's final state (normal/disabled) # contsName - variable name for contents to be set in the widget if {$contsName ne {}} { upvar 1 $contsName conts $w replace 1.0 end $conts } $w edit reset $w edit modified no $w configure -state $state }



scrolledFrame [::apave::APave]APave, Top

OBJECT scrolledFrame w ?args?
Parameters
wNot documented.
argsOptional arguments.

method scrolledFrame {w args} { lassign [::apave::extractOptions args -toplevel no -anchor center -mode both] tl anc mode ::apave::sframe new $w -toplevel $tl -anchor $anc -mode $mode # Retrieve the path where the scrollable contents go. set path [::apave::sframe content $w] return $path }



setTextBinds [::apave::APave]APave, Top

Returns bindings for a text widget.

OBJECT setTextBinds wt
Parameters
wtthe text's path
Return value

Returns bindings for a text widget.


method setTextBinds {wt} { # Returns bindings for a text widget. # wt - the text's path if {[bind $wt <<Paste>>] eq {}} { set res " ::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 " ; ::apave::bindToEvent $wt <$k> [self] doubleText $wt" } foreach k [::apave::getTextHotkeys CtrlY] { append res " ; ::apave::bindToEvent $wt <$k> [self] deleteLine $wt" } foreach k [::apave::getTextHotkeys CtrlA] { append res " ; ::apave::bindToEvent $wt <$k> $wt tag add sel 1.0 end {;} break" } append res " ; ::apave::bindToEvent $wt <Alt-Up> [self] linesMove $wt -1 ; ::apave::bindToEvent $wt <Alt-Down> [self] linesMove $wt +1" return $res }



showModal [::apave::APave]APave, Top

Shows a window as modal.

OBJECT showModal win ?args?
Parameters
winwindow's name
argsattributes of window ("-name value" pairs)

method showModal {win args} { # Shows a window as modal. # win - window's name # args - attributes of window ("-name value" pairs) set shal [::apave::shadowAllowed 0] if {[::apave::getOption -themed {*}$args] in {{} {0}} && [my csCurrent] != [apave::cs_Non]} { my colorWindow $win } set ::apave::MODALWINDOW $win ::apave::setAppIcon $win lassign [my csGet] - - - bg $win configure -bg $bg ;# removes blinking by default bg set _pav(modalwin) $win set root [winfo parent $win] if {[set centerme [::apave::getOption -centerme {*}$args]] ne {}} { ;# forced centering relative to a caller's window if {[winfo exist $centerme]} {set root $centerme} } if {[set ontop [::apave::getOption -ontop {*}$args]] eq {}} { set ontop no catch { set ontop [wm attributes [winfo parent $win] -topmost] } if {!$ontop} { # find if a window child of "." is topmost # if so, let this one be topmost too foreach w [winfo children .] { catch {set ontop [wm attributes $w -topmost]} if {$ontop} break } } } if {[set modal [::apave::getOption -modal {*}$args]] eq {}} { set modal yes } set minsize [::apave::getOption -minsize {*}$args] set args [::apave::removeOptions $args -centerme -ontop -modal -minsize -themed] array set opt [list -focus {} -onclose {} -geometry {} -decor 1 -root $root -resizable {} -variable {} -escape 1 {*}$args] lassign [split [wm geometry $root] x+] rw rh rx ry if {[winfo parent $win] ni {{} .}} { set opt(-decor) 0 } if {!$opt(-decor)} { wm transient $win $root } if {$opt(-onclose) eq {}} { set opt(-onclose) [list set ${_pav(ns)}PN::AR($win) 0] } else { set opt(-onclose) [list $opt(-onclose) ${_pav(ns)}PN::AR($win)] } if {$opt(-resizable) ne {}} { wm resizable $win {*}$opt(-resizable) } set opt(-onclose) "::apave::obj EXPORT CleanUps $win; $opt(-onclose)" wm protocol $win WM_DELETE_WINDOW $opt(-onclose) # get the window's geometry from its requested sizes set inpgeom $opt(-geometry) if {$inpgeom eq {}} { # this is for less blinking: set opt(-geometry) [my CenteredXY $rw $rh $rx $ry [winfo reqwidth $win] [winfo reqheight $win]] } elseif {[string first pointer $inpgeom]==0} { lassign [split $inpgeom+0+0 +] -> x y set inpgeom +[expr {$x+[winfo pointerx .]}]+[expr {$y+[winfo pointery .]}] set opt(-geometry) $inpgeom } elseif {[string first root $inpgeom]==0} { set root .[string trimleft [string range $inpgeom 5 end] .] set opt(-geometry) [set inpgeom {}] } if {[set pp [string first + $opt(-geometry)]]>=0} { wm geometry $win [string range $opt(-geometry) $pp end] } if {$opt(-focus) eq {}} { set opt(-focus) $win } set ${_pav(ns)}PN::AR($win) {-} if {$opt(-escape)} {bind $win <Escape> $opt(-onclose)} update set w [winfo width $win] set h [winfo height $win] if {$inpgeom eq {}} { ;# final geometrizing with actual sizes if {($h/2-$ry-$rh/2)>30 && $root ne "."} { # ::tk::PlaceWindow needs correcting in rare cases, namely: # when 'root' is of less sizes than 'win' and at screen top wm geometry $win [my CenteredXY $rw $rh $rx $ry $w $h] } else { ::tk::PlaceWindow $win widget $root } } else { lassign [lrange [split $inpgeom +] end-1 end] x y if {$x ne {} && $y ne {} && [string first x $inpgeom]<0} { set inpgeom [my checkXY $w $h $x $y] } wm geometry $win $inpgeom } if {[set var $opt(-variable)] eq {}} {set var ${_pav(ns)}PN::AR($win)} after 50 [list if "\[winfo exist $opt(-focus)\]" "focus -force $opt(-focus)"] my showWindow $win $modal $ontop $var $minsize set res 0 catch { my GetOutputValues set res [set [set _ ${_pav(ns)}PN::AR($win)]] } ::apave::shadowAllowed $shal ;# restore shadowing return $res }



showWindow [::apave::APave]APave, Top

Displays a windows and goes in tkwait cycle to interact with a user.

OBJECT showWindow win modal ontop ?var? ?minsize?
Parameters
winthe window's path
modalyes at showing the window as modal
ontopyes at showing the window as topmost
varvariable's name to receive a result (tkwait's variable); optional, default ""
minsizelist {minwidth minheight} or {}; optional, default ""

method showWindow {win modal ontop {var {}} {minsize {}}} { # Displays a windows and goes in tkwait cycle to interact with a user. # win - the window's path # modal - yes at showing the window as modal # ontop - yes at showing the window as topmost # var - variable's name to receive a result (tkwait's variable) # minsize - list {minwidth minheight} or {} ::apave::InfoWindow [expr {[::apave::InfoWindow] + 1}] $win $modal $var yes if {[::iswindows]} { if {[wm attributes $win -alpha] < 0.1} {wm attributes $win -alpha 1.0} } else { catch {wm deiconify $win ; raise $win} } if {$minsize eq {}} { set minsize [list [winfo width $win] [winfo height $win]] } wm minsize $win {*}$minsize bind $win <Configure> "[namespace current]::WinResize $win" if {$ontop} {wm attributes $win -topmost 1} if {$modal} { grab set $win } elseif {[set wgr [grab current]] ne {}} { grab release $wgr } if {![::iswindows]} {tkwait visibility $win} if {$var ne {}} { tkwait variable $var if {$modal} {grab release $win} ::apave::InfoWindow [expr {[::apave::InfoWindow] - 1}] $win $modal $var } }



textLink [::apave::APave]APave, Top

Gets a label's path of a link in a text widget.

OBJECT textLink w idx
Parameters
wtext's path
idxindex of the link

method textLink {w idx} { # Gets a label's path of a link in a text widget. # w - text's path # idx - index of the link if {[info exists ::apave::__TEXTLINKS__($w)]} { return [lindex $::apave::__TEXTLINKS__($w) $idx] } return {} }



themePopup [::apave::APave]APave, Top

Applies a color scheme to a popup menu.

OBJECT themePopup mnu
Parameters
mnuname of popup menu
Description

The method is to be redefined in descendants/mixins.


method themePopup {mnu} { # Applies a color scheme to a popup menu. # mnu - name of popup menu # The method is to be redefined in descendants/mixins. return }



timeoutButton [::apave::APave]APave, Top

Invokes a button's action after a timeout.

OBJECT timeoutButton w tmo lbl ?lbltext?
Parameters
wbutton's path
tmotimeout in sec.
lbllabel widget, where seconds to wait are displayed
lbltextoriginal text of label; optional, default ""

method timeoutButton {w tmo lbl {lbltext {}}} { # Invokes a button's action after a timeout. # w - button's path # tmo - timeout in sec. # lbl - label widget, where seconds to wait are displayed # lbltext - original text of label if {$tmo>0} { catch {set lbl [my $lbl]} if {[winfo exist $lbl]} { if {$lbltext eq {}} { set lbltext [$lbl cget -text] lappend ::apave::_AP_VARS(TIMW) $w } $lbl configure -text "$lbltext $tmo sec. " } incr tmo -1 after 1000 [list if "\[info commands [self]\] ne {}" "[self] checkTimeoutButton $w $tmo $lbl {$lbltext}"] return } if {[winfo exist $w]} {$w invoke} return }



tk_optionCascade [::apave::APave]APave, Top

A bit modified tk_optionCascade widget made by Richard Suchenwirth.

OBJECT tk_optionCascade w vname items ?mbopts? ?precom? ?args?
Parameters
wwidget name
vnamevariable name for current selection
itemslist of items
mboptsttk::menubutton options (e.g. "-width -4"); optional, default ""
precomcommand to get entry's options (%a presents its label); optional, default ""
argsadditional options of entries
Return value

Returns a path to the widget.

See also

optionCascadeText, wiki.tcl-lang.org


method tk_optionCascade {w vname items {mbopts {}} {precom {}} args} { # A bit modified tk_optionCascade widget made by Richard Suchenwirth. # w - widget name # vname - variable name for current selection # items - list of items # mbopts - ttk::menubutton options (e.g. "-width -4") # precom - command to get entry's options (%a presents its label) # args - additional options of entries # # Returns a path to the widget. # # See also: # optionCascadeText # [wiki.tcl-lang.org](https://wiki.tcl-lang.org/page/tk_optionCascade) if {![info exists $vname]} { set it [lindex $items 0] while {[llength $it]>1} {set it [lindex $it 0]} set it [my optionCascadeText $it] set $vname $it } lassign [::apave::extractOptions mbopts -tip {} -tooltip {} -com {} -command {}] tip tip2 com com2 if {$tip eq {}} {set tip $tip2} if {$com eq {}} {set com $com2} if {$com ne {}} {lappend args -command $com} ttk::menubutton $w -menu $w.m -text [set $vname] -style TMenuButtonWest {*}$mbopts if {$tip ne {}} { set tip [my MC $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 ::apave::bindToEvent $w <ButtonPress> focus $w return $w.m }



validateColorChoice [::apave::APave]APave, Top

Displays a current color of color chooser's entry.

OBJECT validateColorChoice lab ent
Parameters
lablabel to display
entcolor chooser's entry

method validateColorChoice {lab ent} { # Displays a current color of color chooser's entry. # lab - label to display # ent - color chooser's entry set ent [my ownWName $ent] set lab [my [my ownWName $lab]] set val [[my $ent] get] set tvar [[my $ent] cget -textvariable] catch {$lab configure -background $val} return yes }



widgetType [::apave::APave]APave, Top

Gets the widget type based on 3 initial letters of its name. Also fills the grid/pack options and attributes of the widget.

OBJECT widgetType wnamefull options attrs
Parameters
wnamefullpath to the widget
optionsgrid/pack options of the widget
attrsattribute of the widget
Description

The widgetType method returns a list of items:

widgetTk/Ttk widget name
optionsgrid/pack options of the widget
attrsattribute of the widget
nam33 initial letters of widget's name
disabledflag of disabled state

method widgetType {wnamefull options attrs} { # Gets the widget type based on 3 initial letters of its name. Also # fills the grid/pack options and attributes of the widget. # wnamefull - path to the widget # options - grid/pack options of the widget # attrs - attribute of the widget # # The *widgetType* method returns a list of items: # widget - Tk/Ttk widget name # options - grid/pack options of the widget # attrs - attribute of the widget # nam3 - 3 initial letters of widget's name # disabled - flag of *disabled* state set disabled [expr {[::apave::getOption -state {*}$attrs] eq {disabled}}] set pack $options set name [my ownWName $wnamefull] if {[info exists ::apave::_AP_VARS(ProSplash,type)] && $::apave::_AP_VARS(ProSplash,type) eq {}} { set val [my progress_Go [incr ::apave::_AP_VARS(ProSplash,curvalue)] {} $name] } set nam3 [string tolower [string index $name 0]][string range $name 1 2] if {[string index $nam3 1] eq "_"} {set k [string range $nam3 0 1]} {set k $nam3} lassign [dict get $::apave::_Defaults $k] defopts defattrs set options "[subst $defopts] $options" set attrs "[subst $defattrs] $attrs" switch -glob -- $nam3 { bts { set widget ttk::frame if {![info exists ::bartabs::NewBarID]} {package require bartabs} set attrs "-bartabs {$attrs}" } but { set widget ttk::button my AddButtonIcon $name attrs } buT { set widget button my AddButtonIcon $name attrs } can {set widget canvas} chb {set widget ttk::checkbutton} swi { set widget ttk::checkbutton if {![my apaveTheme]} { set attrs "$attrs -style Switch.TCheckbutton" } } chB {set widget checkbutton} cbx - fco { set widget ttk::combobox if {$nam3 eq {fco}} { ;# file content combobox set attrs [my FCfieldValues $wnamefull $attrs] } set attrs [my FCfieldAttrs $wnamefull $attrs -tvar] } ent {set widget ttk::entry} enT {set widget entry} fil - fiL - fis - fiS - dir - diR - fon - foN - clr - clR - dat - daT - sta - too - fra { # + frame for choosers and bars set widget ttk::frame } frA { set widget frame if {$disabled} {set attrs [::apave::removeOptions $attrs -state]} } ftx {set widget ttk::labelframe} gut {set widget canvas} lab { set widget ttk::label if {[::apave::extractOptions attrs -state normal] eq "disabled"} { set grey [lindex [my csGet] 8] set attrs "-foreground $grey $attrs" } lassign [::apave::parseOptions $attrs -link {} -style {} -font {}] cmd style font if {$cmd ne {}} { set attrs "-linkcom {$cmd} $attrs" set attrs [::apave::removeOptions $attrs -link] } if {$style eq {} && $font eq {}} { set attrs "-font {$::apave::FONTMAIN} $attrs" } elseif {$style ne {}} { # some themes stumble at ttk styles, so bring their attrs directly set attrs [::apave::removeOptions $attrs -style] set attrs "[ttk::style configure $style] $attrs" } } laB {set widget label} lfr {set widget ttk::labelframe} lfR { set widget labelframe if {$disabled} {set attrs [::apave::removeOptions $attrs -state]} } lbx - flb { set widget listbox if {$nam3 eq {flb}} { ;# file content listbox set attrs [my FCfieldValues $wnamefull $attrs] } set attrs "[my FCfieldAttrs $wnamefull $attrs -lvar]" set attrs "[my ListboxesAttrs $wnamefull $attrs]" my AddPopupAttr $wnamefull attrs -entrypop 1 foreach {ev com} {Home {::apave::LbxSelect %w 0} End {::apave::LbxSelect %w end}} { append attrs " -bindEC {<$ev> {$com}} " } } meb {set widget ttk::menubutton} meB {set widget menubutton} nbk { set widget ttk::notebook set attrs "-notebazook {$attrs}" } opc { ;# tk_optionCascade - example of "my method" widget ;# arguments: vname items mbopts precom args set widget {my tk_optionCascade} set imax [expr {min(4,[llength $attrs])}] for {set i 0} {$i<$imax} {incr i} { set atr [lindex $attrs $i] if {$i!=1} { lset attrs $i \{$atr\} } elseif {[llength $atr]==1 && [info exist $atr]} { lset attrs $i [set $atr] ;# items stored in a variable } } } pan {set widget ttk::panedwindow if {[string first -w $attrs]>-1 && [string first -h $attrs]>-1} { # important for panes with fixed (customized) dimensions set attrs "-propagate {$options} $attrs" } } pro {set widget ttk::progressbar} rad {set widget ttk::radiobutton} raD {set widget radiobutton} sca {set widget ttk::scale} scA {set widget scale} sbh {set widget ttk::scrollbar} sbH {set widget scrollbar} sbv {set widget ttk::scrollbar} sbV {set widget scrollbar} scf { if {![namespace exists ::apave::sframe]} { namespace eval ::apave { source [file join $::apave::apaveDir sframe.tcl] } } ;# scrolledFrame - example of "my method" widget set widget {my scrolledFrame} } seh {set widget ttk::separator} sev {set widget ttk::separator} siz {set widget ttk::sizegrip} spx - spX { if {$nam3 eq {spx}} {set widget ttk::spinbox} {set widget spinbox} lassign [::apave::parseOptions $attrs -command {} -com {} -from {} -to {}] cmd cmd2 from to append cmd $cmd2 lassign [::apave::extractOptions attrs -tip {} -tooltip {}] t1 t2 set t2 "$t1$t2" if {$t2 ne {}} {set t2 "\n $t2"} set t2 " $from .. $to $t2" append attrs " -onReturn {$::apave::UFF{$cmd} {$from} {$to}$::apave::UFF} -tip {$t2}" } tbl { ;# tablelist package require tablelist set widget tablelist::tablelist set attrs "[my FCfieldAttrs $wnamefull $attrs -lvar]" set attrs "[my ListboxesAttrs $wnamefull $attrs]" } tex {set widget text if {[::apave::getOption -textpop {*}$attrs] eq {}} { my AddPopupAttr $wnamefull attrs -textpop [expr {[::apave::getOption -rotext {*}$attrs] ne {}}] -- disabled } lassign [::apave::parseOptions $attrs -ro {} -readonly {} -rotext {} -gutter {} -gutterwidth 5 -guttershift 6] r1 r2 r3 g1 g2 g3 set b1 [expr [string is boolean -strict $r1]] set b2 [expr [string is boolean -strict $r2]] if {($b1 && $r1) || ($b2 && $r2) || ($r3 ne {} && !($b1 && !$r1) && !($b2 && !$r2))} { set attrs "-takefocus 0 $attrs" } set attrs [::apave::removeOptions $attrs -gutter -gutterwidth -guttershift] if {$g1 ne {}} { set attrs "$attrs -gutter {-canvas $g1 -width $g2 -shift $g3}" } } tre { set widget ttk::treeview foreach {ev com} {Home {::apave::TreSelect %w 0} End {::apave::TreSelect %w end}} { append attrs " -bindEC {<$ev> {$com}} " } } h_* {set widget ttk::frame} v_* {set widget ttk::frame} default {set widget {}} } set attrs [my GetMC $attrs] if {$nam3 in {cbx ent enT fco spx spX}} { ;# entry-like widgets need their popup menu my AddPopupAttr $wnamefull attrs -entrypop 0 readonly disabled } if {[string first pack [string trimleft $pack]]==0} { catch { # try to expand -after option (if set as WidgetName instead widgetName) if {[set i [lsearch -exact $pack {-after}]]>=0} { set aft [lindex $pack [incr i]] if {[regexp {^[A-Z]} $aft]} { set aft [my $aft] set pack [lreplace $pack $i $i $aft] } } } set options $pack } set options [string trim $options] set attrs [list {*}$attrs] return [list $widget $options $attrs $nam3 $disabled] }



window [::apave::APave]APave, Top

Obsolete version of paveWindow (remains for compatibility).

OBJECT window ?args?
Parameters
argsOptional arguments.
See also

paveWindow


method window {args} { # Obsolete version of paveWindow (remains for compatibility). # See also: paveWindow return [uplevel 1 [list [self] paveWindow {*}$args]] }



APaveDialog [::apave]apave, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
abortretrycancelShows the ABORTRETRYCANCEL dialog.
apaveThemeSee ObjectTheming.apaveTheme
basicDefFontSee ObjectTheming.basicDefFont
basicFontSizeSee ObjectTheming.basicFontSize
basicSmallFontSee ObjectTheming.basicSmallFont
basicTextFontSee ObjectTheming.basicTextFont
boldDefFontSee ObjectTheming.boldDefFont
boldTextFontSee ObjectTheming.boldTextFont
checkTimeoutButtonSee APave.checkTimeoutButton
checkXYSee APave.checkXY
chooserSee APave.chooser
colorChooserSee APave.colorChooser
colorWindowSee APave.colorWindow
configureSee APave.configure
create_FontsSee ObjectTheming.create_Fonts
create_FontsTypeSee ObjectTheming.create_FontsType
csAddSee ObjectTheming.csAdd
csCurrentSee ObjectTheming.csCurrent
csDarkSee ObjectTheming.csDark
csDeleteExternalSee ObjectTheming.csDeleteExternal
csExportSee ObjectTheming.csExport
csFontSee ObjectTheming.csFont
csFontDefSee ObjectTheming.csFontDef
csFontMonoSee ObjectTheming.csFontMono
csGetSee ObjectTheming.csGet
csGetNameSee ObjectTheming.csGetName
csMainColorsSee ObjectTheming.csMainColors
csMapThemeSee ObjectTheming.csMapTheme
csSetSee ObjectTheming.csSet
csTonedSee ObjectTheming.csToned
dateChooserSee APave.dateChooser
defaultAttrsSee APave.defaultAttrs
deleteLineDeletes a current line of text widget.
displayTaggedTextSee APave.displayTaggedText
displayTextSee APave.displayText
doubleTextDoubles a current line or a selection of text widget.
fillGutterSee APave.fillGutter
findInTextFinds a string in text widget.
findWidPathSee APave.findWidPath
focusNextSee APave.focusNext
fontChooserSee APave.fontChooser
get_highlightedGets a selected word after double-clicking on a text.
get_HighlightedStringReturns a string got from highlighting by Alt+left/right/q/w.
getPropertySee ObjectProperty.getProperty
getTextContentSee APave.getTextContent
getWidChildrenSee APave.getWidChildren
highlight_matchesHighlights matches of selected word in a text.
iconASee APave.iconA
initLinkFontSee APave.initLinkFont
initTooltipSee ObjectTheming.initTooltip
labelFlashingSee APave.labelFlashing
leadingSpacesSee APave.leadingSpaces
linesMoveMoves a current line or lines of selection up/down.
makeLabelLinkedSee APave.makeLabelLinked
makePopupSee APave.makePopup
makeWindowSee APave.makeWindow
miscShows the MISCELLANEOUS dialog.
okShows the OK dialog.
okcancelShows the OKCANCEL dialog.
onKeyTextMSee APave.onKeyTextM
optionCascadeTextSee APave.optionCascadeText
ownWNameSee APave.ownWName
parentWNameSee APave.parentWName
pasteTextRemoves a selection at pasting.
paveoptionValueSee APave.paveoptionValue
paveWindowSee APave.paveWindow
popupBlockCommandsReturns block commands for a popup menu on a text.
popupFindCommandsReturns find commands for a popup menu on a text.
popupHighlightCommandsReturns highlighting commands for a popup menu on a text.
progress_BeginCreates and shows a progress window. Fit for splash screens.
progress_EndDestroys a progress window.
progress_GoUpdates a progress window.
readonlyWidgetSee APave.readonlyWidget
resSee APave.res
resetTextSee APave.resetText
retrycancelShows the RETRYCANCEL dialog.
scrolledFrameSee APave.scrolledFrame
seek_highlightSeeks the selected word forward/backward/to first/to last in a text.
selectedWordTextReturns a word under the cursor or a selected text.
set_highlight_matchesCreates bindings to highlight matches in a text.
set_HighlightedStringSaves a string got from highlighting by Alt+left/right/q/w.
setPropertySee ObjectProperty.setProperty
setTextBindsSee APave.setTextBinds
showModalSee APave.showModal
showWindowSee APave.showWindow
textLinkSee APave.textLink
themeExternalSee ObjectTheming.themeExternal
themeMandatorySee ObjectTheming.themeMandatory
themeNonThemedSee ObjectTheming.themeNonThemed
themePopupSee ObjectTheming.themePopup
themeWindowSee ObjectTheming.themeWindow
timeoutButtonSee APave.timeoutButton
tk_optionCascadeSee APave.tk_optionCascade
unhighlight_matchesUnhighlights matches of selected word in a text.
untouchWidgetsSee ObjectTheming.untouchWidgets
validateColorChoiceSee APave.validateColorChoice
widgetTypeSee APave.widgetType
windowSee APave.window
yesnoShows the YESNO dialog.
yesnocancelShows the YESNOCANCEL dialog.
Superclasses

APave

Subclasses

APaveInput



constructor [::apave::APaveDialog]APaveDialog, Top

Creates APaveDialog object.

APaveDialog create ?win? ?args?
Parameters
winwindow's name (path); optional, default ""
argsadditional arguments

method constructor {{win {}} args} { # Creates APaveDialog object. # win - window's name (path) # args - additional arguments # keep the 'important' data of APaveDialog object in array array set _pdg {} # dialogs are bound to "$win" window e.g. ".mywin.fra", default "" means . set _pdg(win) $win set _pdg(ns) [namespace current]:: # namespace in object namespace for safety of its 'most important' data namespace eval ${_pdg(ns)}PD {} # Actions on closing the editor proc exitEditor {resExit} { upvar $resExit res if {[[my TexM] edit modified]} { set w [set [namespace current]::_pdg(dlg)] set pdlg [::apave::APaveDialog new $w] set r [$pdlg misc warn "Save text?" "\n Save changes made to the text? \n" {Save 1 "Don't save " Close Cancel 0} 1 -focusback [my TexM] -centerme $w] if {$r==1} { set res 1 } elseif {$r eq "Close"} { set res 0 } $pdlg destroy } else { set res 0 } return } # end of APaveDialog constructor if {[llength [self next]]} { next {*}$args } }



destructor [::apave::APaveDialog]APaveDialog, Top

Clears variables used in the object.

OBJECT destroy

method destructor {} { # Clears variables used in the object. catch {namespace delete ${_pdg(ns)}PD} array unset _pdg if {[llength [self next]]} next }



abortretrycancel [::apave::APaveDialog]APaveDialog, Top

Shows the ABORTRETRYCANCEL dialog.

OBJECT abortretrycancel icon ttl msg ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
defbbutton to be selected; optional, default RETRY
argsoptions

method abortretrycancel {icon ttl msg {defb RETRY} args} { # Shows the *ABORTRETRYCANCEL* dialog. # icon - icon # ttl - title # msg - message # defb - button to be selected # args - options return [my Query $icon $ttl $msg {ButABORT Abort 1 ButRETRY Retry 2 ButCANCEL Cancel 0} But$defb {} [my PrepArgs $args]] }



deleteLine [::apave::APaveDialog]APaveDialog, Top

Deletes a current line of text widget.

OBJECT deleteLine txt ?dobreak?
Parameters
txttext's path
dobreakif true, means "return -code break" optional, default 1
Description

The dobreak=true allows to break the Tk processing of keypresses such as Ctrl+Y.

If not set, the text widget is identified as my TexM.


method deleteLine {txt {dobreak 1}} { # Deletes a current line of text widget. # txt - text's path # dobreak - if true, means "return -code break" # # The *dobreak=true* allows to break the Tk processing of keypresses # such as Ctrl+Y. # # If not set, the text widget is identified as `my TexM`. if {$txt eq {}} {set txt [my TexM]} lassign [my GetLinePosition $txt insert] linestart lineend $txt delete $linestart $lineend if {$dobreak} {return -code break} return }



doubleText [::apave::APaveDialog]APaveDialog, Top

Doubles a current line or a selection of text widget.

OBJECT doubleText txt ?dobreak?
Parameters
txttext's path
dobreakif true, means "return -code break" optional, default 1
Description

The dobreak=true allows to break the Tk processing of keypresses such as Ctrl+D.

If not set, the text widget is identified as my TexM.


method doubleText {txt {dobreak 1}} { # Doubles a current line or a selection of text widget. # txt - text's path # dobreak - if true, means "return -code break" # # The *dobreak=true* allows to break the Tk processing of keypresses # such as Ctrl+D. # # If not set, the text widget is identified as `my TexM`. if {$txt eq {}} {set txt [my TexM]} set err [catch {$txt tag ranges sel} sel] if {!$err && [llength $sel]==2} { lassign $sel pos pos2 set pos3 insert ;# single selection } else { lassign [my GetLinePosition $txt insert] pos pos2 ;# current line set pos3 $pos2 } set duptext [$txt get $pos $pos2] if {$pos3 ne {insert} && $pos2==[$txt index end]} { # current line is the last one: duplicate it properly set duptext \n[string range $duptext 0 end-1] } $txt insert $pos3 $duptext if {$dobreak} {return -code break} return }



findInText [::apave::APaveDialog]APaveDialog, Top

Finds a string in text widget.

OBJECT findInText ?donext? ?txt? ?varFind?
Parameters
donext"1" means 'from a current position'; optional, default 0
txtpath to the text widget; optional, default ""
varFindvariable; optional, default ""

method findInText {{donext 0} {txt {}} {varFind {}}} { # Finds a string in text widget. # donext - "1" means 'from a current position' # txt - path to the text widget # varFind - variable if {$txt eq {}} { if {![info exists ${_pdg(ns)}PD::fnd]} return set txt [my TexM] set sel [set ${_pdg(ns)}PD::fnd] } elseif {$donext && [set sel [my get_HighlightedString]] ne {}} { # find a string got with alt+left/right } elseif {$varFind eq {}} { if {![info exists ${_pdg(ns)}PD::fnd]} return set sel [set ${_pdg(ns)}PD::fnd] } else { set sel [set $varFind] } if {$donext} { set pos [$txt index insert] if {{sel} in [$txt tag names $pos]} { set pos [$txt index "$pos + 1 chars"] } set pos [$txt search -- $sel $pos end] } else { set pos {} my set_HighlightedString {} } if {![string length "$pos"]} { set pos [$txt search -- $sel 1.0 end] } if {[string length "$pos"]} { ::tk::TextSetCursor $txt $pos $txt tag add sel $pos [$txt index "$pos + [string length $sel] chars"] focus $txt } else { bell -nice } return }



get_highlighted [::apave::APaveDialog]APaveDialog, Top

Gets a selected word after double-clicking on a text.

OBJECT get_highlighted txt
Parameters
txtNot documented.
wpath to the text

method get_highlighted {txt} { # Gets a selected word after double-clicking on a text. # w - path to the text set err [catch {$txt tag ranges sel} sel] lassign $sel pos pos2 if {!$err && [llength $sel]==2} { set sel [$txt get $pos $pos2] ;# single selection } else { if {$err || [string trim $sel] eq {}} { set pos [$txt index "insert wordstart"] set pos2 [$txt index "insert wordend"] set sel [string trim [$txt get $pos $pos2]] if {![string is wordchar -strict $sel]} { # when cursor just at the right of word: take the word at the left # e.g. if "_" stands for cursor then "word_" means selecting "word" set pos [$txt index "insert -1 char wordstart"] set pos2 [$txt index "insert -1 char wordend"] set sel [$txt get $pos $pos2] } } } if {[string length $sel] == 0} {set pos {}} return [list $sel $pos $pos2] }



get_HighlightedString [::apave::APaveDialog]APaveDialog, Top

Returns a string got from highlighting by Alt+left/right/q/w.

OBJECT get_HighlightedString
Return value

Returns a string got from highlighting by Alt+left/right/q/w.


method get_HighlightedString {} { # Returns a string got from highlighting by Alt+left/right/q/w. if {[info exists _pdg(hlstring)]} { return $_pdg(hlstring) } return {} }



highlight_matches [::apave::APaveDialog]APaveDialog, Top

Highlights matches of selected word in a text.

OBJECT highlight_matches txt
Parameters
txtNot documented.
wpath to the text

method highlight_matches {txt} { # Highlights matches of selected word in a text. # w - path to the text lassign [my get_highlighted $txt] sel pos if {$pos eq {}} return my set_HighlightedString $sel set lenList {} set posList [$txt search -all -count lenList -- "$sel" 1.0 end] foreach pos2 $posList len $lenList { if {$len eq {}} {set len [string length $sel]} set pos3 [$txt index "$pos2 + $len chars"] if {$pos2 == $pos} { lappend matches2 $pos2 $pos3 } else { lappend matches1 $pos2 $pos3 } } catch { $txt tag remove hilited 1.0 end $txt tag remove hilited2 1.0 end $txt tag add hilited {*}$matches1 $txt tag add hilited2 {*}$matches2 } set ::apave::_AP_VARS(HILI,$txt) yes }



linesMove [::apave::APaveDialog]APaveDialog, Top

Moves a current line or lines of selection up/down.

OBJECT linesMove txt to ?dobreak?
Parameters
txttext's path
todirection (-1 means "up", +1 means "down")
dobreakif true, means "return -code break" optional, default 1
Description

The dobreak=true allows to break the Tk processing of keypresses such as Ctrl+Y.

If not set, the text widget is identified as my TexM.


method linesMove {txt to {dobreak 1}} { # Moves a current line or lines of selection up/down. # txt - text's path # to - direction (-1 means "up", +1 means "down") # dobreak - if true, means "return -code break" # # The *dobreak=true* allows to break the Tk processing of keypresses # such as Ctrl+Y. # # If not set, the text widget is identified as `my TexM`. proc NewRow {ind rn} { set i [string first . $ind] set row [string range $ind 0 $i-1] return [incr row $rn][string range $ind $i end] } if {$txt eq {}} {set txt [my TexM]} set err [catch {$txt tag ranges sel} sel] lassign [$txt index insert] pos ;# position of caret if {[set issel [expr {!$err && [llength $sel]==2}]]} { lassign $sel pos1 pos2 ;# selection's start & end set l1 [expr {int($pos1)}] set l2 [expr {int($pos2)}] set pos21 [$txt index "$pos2 linestart"] if {[$txt get $pos21 $pos2] eq {}} {incr l2 -1} set lfrom [expr {$to>0 ? $l2+1 : $l1-1}] set lto [expr {$to>0 ? $l1-1 : $l2-1}] } else { set lcurr [expr {int($pos)}] set lfrom [expr {$to>0 ? $lcurr+1 : $lcurr-1}] set lto [expr {$to>0 ? $lcurr-1 : $lcurr-1}] } set lend [expr {int([$txt index end])}] if {$lfrom>0 && $lfrom<$lend} { incr lto lassign [my GetLinePosition $txt $lfrom.0] linestart lineend set duptext [$txt get $linestart $lineend] $txt configure -autoseparators no $txt edit separator $txt delete $linestart $lineend $txt insert $lto.0 $duptext ::tk::TextSetCursor $txt [NewRow $pos $to] if {$issel} { $txt tag add sel [NewRow $pos1 $to] [NewRow $pos2 $to] } if {[lsearch -glob [$txt tag names] tagCOM*]>-1} { catch {::hl_tcl::my::Modified $txt insert $lto.0 $lto.end} } $txt edit separator $txt configure -autoseparators yes if {$dobreak} {return -code break} } return }



misc [::apave::APaveDialog]APaveDialog, Top

Shows the MISCELLANEOUS dialog.

OBJECT misc icon ttl msg butts ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
buttslist of buttons
defbbutton to be selected; optional, default ""
argsoptions
Description

The butts is a list of pairs "title of button" "number/ID of button"


method misc {icon ttl msg butts {defb {}} args} { # Shows the *MISCELLANEOUS* dialog. # icon - icon # ttl - title # msg - message # butts - list of buttons # defb - button to be selected # args - options # # The *butts* is a list of pairs "title of button" "number/ID of button" foreach {nam num} $butts { lappend apave_msc_bttns But$num "$nam" $num if {$defb eq {}} { set defb $num } } return [my Query $icon $ttl $msg $apave_msc_bttns But$defb {} [my PrepArgs $args]] }



ok [::apave::APaveDialog]APaveDialog, Top

Shows the OK dialog.

OBJECT ok icon ttl msg ?args?
Parameters
iconicon
ttltitle
msgmessage
argsoptions

method ok {icon ttl msg args} { # Shows the *OK* dialog. # icon - icon # ttl - title # msg - message # args - options return [my Query $icon $ttl $msg {ButOK OK 1} ButOK {} [my PrepArgs $args]] }



okcancel [::apave::APaveDialog]APaveDialog, Top

Shows the OKCANCEL dialog.

OBJECT okcancel icon ttl msg ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
defbbutton to be selected; optional, default OK
argsoptions

method okcancel {icon ttl msg {defb OK} args} { # Shows the *OKCANCEL* dialog. # icon - icon # ttl - title # msg - message # defb - button to be selected # args - options return [my Query $icon $ttl $msg {ButOK OK 1 ButCANCEL Cancel 0} But$defb {} [my PrepArgs $args]] }



pasteText [::apave::APaveDialog]APaveDialog, Top

Removes a selection at pasting.

OBJECT pasteText txt
Parameters
txttext's path
Description

The absence of this feature is very perpendicular of Tk's paste.


method pasteText {txt} { # Removes a selection at pasting. # txt - text's path # # The absence of this feature is very perpendicular of Tk's paste. set err [catch {$txt tag ranges sel} sel] if {!$err && [llength $sel]==2} { lassign $sel pos1 pos2 set pos [$txt index insert] if {[$txt compare $pos >= $pos1] && [$txt compare $pos <= $pos2]} { $txt delete $pos1 $pos2 } } }



popupBlockCommands [::apave::APaveDialog]APaveDialog, Top

Returns block commands for a popup menu on a text.

OBJECT popupBlockCommands pop ?txt?
Parameters
poppath to the menu
txtpath to the text; optional, default ""
Return value

Returns block commands for a popup menu on a text.


method popupBlockCommands {pop {txt {}}} { # Returns block commands for a popup menu on a text. # 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 $accD -label \"Double Selection\" \\ -command \"[self] doubleText {$txt} 0\" \$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\" \$pop add command [my iconA down] -accelerator Alt+Down -label \"Line(s) Down\" \\ -command \"[self] linesMove {$txt} +1 0\"" }



popupFindCommands [::apave::APaveDialog]APaveDialog, Top

Returns find commands for a popup menu on a text.

OBJECT popupFindCommands pop ?txt? ?com1? ?com2?
Parameters
poppath to the menu
txtpath to the text; optional, default ""
com1user's command "find first" optional, default ""
com2user's command "find next" optional, default ""
Return value

Returns find commands for a popup menu on a text.


method popupFindCommands {pop {txt {}} {com1 {}} {com2 {}}} { # Returns find commands for a popup menu on a text. # pop - path to the menu # txt - path to the text # 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 $accF3 -label \"Find Next\" \\ -command {$com2}" }



popupHighlightCommands [::apave::APaveDialog]APaveDialog, Top

Returns highlighting commands for a popup menu on a text.

OBJECT popupHighlightCommands ?pop? ?txt?
Parameters
poppath to the menu; optional, default ""
txtpath to the text; optional, default ""
Return value

Returns highlighting commands for a popup menu on a text.


method popupHighlightCommands {{pop {}} {txt {}}} { # Returns highlighting commands for a popup menu on a text. # pop - path to the menu # txt - path to the text set accQ [::apave::KeyAccelerator [::apave::getTextHotkeys AltQ]] set accW [::apave::KeyAccelerator [::apave::getTextHotkeys AltW]] set res "\$pop add separator \$pop add command [my iconA upload] -accelerator $accQ \\ -label \"Highlight First\" -command \"[self] seek_highlight %w 2\" \$pop add command [my iconA download] -accelerator $accW \\ -label \"Highlight Last\" -command \"[self] seek_highlight %w 3\" \$pop add command [my iconA previous] -accelerator Alt+Left \\ -label \"Highlight Previous\" -command \"[self] seek_highlight %w 0\" \$pop add command [my iconA next] -accelerator Alt+Right \\ -label \"Highlight Next\" -command \"[self] seek_highlight %w 1\" \$pop add command [my iconA none] -accelerator Dbl.Click \\ -label \"Highlight All\" -command \"[self] highlight_matches %w\"" if {$txt ne {}} {set res [string map [list %w $txt] $res]} return $res }



progress_Begin [::apave::APaveDialog]APaveDialog, Top

Creates and shows a progress window. Fit for splash screens.

OBJECT progress_Begin type wprn ttl msg1 msg2 maxvalue ?args?
Parameters
typeany word(s)
wprnparent window
ttltitle message
msg1top message
msg2bottom message
maxvaluemaximum value
argsadditional attributes of the progress bar
Description

If type={}, widgetType method participates too in progress_Go, and also progress_End puts out a little statistics.

See also

APave::widgetType, progress_Go, progress_End


method progress_Begin {type wprn ttl msg1 msg2 maxvalue args} { # Creates and shows a progress window. Fit for splash screens. # type - any word(s) # wprn - parent window # ttl - title message # msg1 - top message # msg2 - bottom message # maxvalue - maximum value # args - additional attributes of the progress bar # # If type={}, widgetType method participates too in progress_Go, and also # progress_End puts out a little statistics. # # See also: APave::widgetType, progress_Go, progress_End set ::apave::_AP_VARS(win) .proSplashScreen set qdlg $::apave::_AP_VARS(win) set atr1 "-maximum 100 -value 0 -mode determinate -length 300 -orient horizontal" set widlist [list "fra - - - - {pack } {-h 10}" ".Lab1SplashScreen - - - - {pack} {-t {$msg1}}" ".ProgSplashScreen - - - - {pack} {$atr1 $args}" ".Lab2SplashScreen - - - - {pack -anchor w} {-t {$msg2}}" ] set win [my makeWindow $qdlg.fra $ttl] set widlist [my paveWindow $qdlg.fra $widlist] ::tk::PlaceWindow $win widget $wprn my showWindow $win 0 1 update set ::apave::_AP_VARS(ProSplash,type) $type set ::apave::_AP_VARS(ProSplash,win) $win set ::apave::_AP_VARS(ProSplash,wid1) [my Lab1SplashScreen] set ::apave::_AP_VARS(ProSplash,wid2) [my ProgSplashScreen] set ::apave::_AP_VARS(ProSplash,wid3) [my Lab2SplashScreen] set ::apave::_AP_VARS(ProSplash,val1) 0 set ::apave::_AP_VARS(ProSplash,val2) 0 set ::apave::_AP_VARS(ProSplash,value) 0 set ::apave::_AP_VARS(ProSplash,curvalue) 0 set ::apave::_AP_VARS(ProSplash,maxvalue) $maxvalue set ::apave::_AP_VARS(ProSplash,after) [list] # 'after' should be postponed, as 'update' messes it up rename ::after ::ProSplash_after proc ::after {args} { lappend ::apave::_AP_VARS(ProSplash,after) $args } }



progress_End [::apave::APaveDialog]APaveDialog, Top

Destroys a progress window.

OBJECT progress_End
See also

progress_Begin


method progress_End {} { # Destroys a progress window. # See also: progress_Begin variable ::apave::_AP_VARS catch { destroy $::apave::_AP_VARS(ProSplash,win) rename ::after {} rename ::ProSplash_after ::after foreach aftargs $::apave::_AP_VARS(ProSplash,after) { after {*}$aftargs } if {$::apave::_AP_VARS(ProSplash,type) eq {}} { puts "Splash statistics: \n \"maxvalue\": $::apave::_AP_VARS(ProSplash,maxvalue) \n curr.value: $::apave::_AP_VARS(ProSplash,val1) \n steps made: $::apave::_AP_VARS(ProSplash,val2)" } unset ::apave::_AP_VARS(ProSplash,type) unset ::apave::_AP_VARS(ProSplash,win) unset ::apave::_AP_VARS(ProSplash,wid1) unset ::apave::_AP_VARS(ProSplash,wid2) unset ::apave::_AP_VARS(ProSplash,wid3) unset ::apave::_AP_VARS(ProSplash,val1) unset ::apave::_AP_VARS(ProSplash,val2) unset ::apave::_AP_VARS(ProSplash,value) unset ::apave::_AP_VARS(ProSplash,curvalue) unset ::apave::_AP_VARS(ProSplash,maxvalue) unset ::apave::_AP_VARS(ProSplash,after) } }



progress_Go [::apave::APaveDialog]APaveDialog, Top

Updates a progress window.

OBJECT progress_Go value ?msg1? ?msg2?
Parameters
valuecurrent value of the progress bar
msg1top message; optional, default ""
msg2bottom message; optional, default ""
Return value

Returns current percents (value) of progress. If it reaches 100, the progress_Go may continue from 0.

See also

progress_Begin


method progress_Go {value {msg1 {}} {msg2 {}}} { # Updates a progress window. # value - current value of the progress bar # msg1 - top message # msg2 - bottom message # # Returns current percents (value) of progress. # If it reaches 100, the progress_Go may continue from 0. # # See also: progress_Begin set ::apave::_AP_VARS(ProSplash,val1) $value incr ::apave::_AP_VARS(ProSplash,val2) set val [expr {min(100,int(100*$value/$::apave::_AP_VARS(ProSplash,maxvalue)))}] if {$val!=$::apave::_AP_VARS(ProSplash,value)} { set ::apave::_AP_VARS(ProSplash,value) $val catch { ;# there might be no splash widgets, then let it run dry $::apave::_AP_VARS(ProSplash,wid2) configure -value $val if {$msg1 ne {}} { $::apave::_AP_VARS(ProSplash,wid1) configure -text $msg1 } if {$msg2 ne {}} { $::apave::_AP_VARS(ProSplash,wid3) configure -text $msg2 } update } } return $val }



retrycancel [::apave::APaveDialog]APaveDialog, Top

Shows the RETRYCANCEL dialog.

OBJECT retrycancel icon ttl msg ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
defbbutton to be selected; optional, default RETRY
argsoptions

method retrycancel {icon ttl msg {defb RETRY} args} { # Shows the *RETRYCANCEL* dialog. # icon - icon # ttl - title # msg - message # defb - button to be selected # args - options return [my Query $icon $ttl $msg {ButRETRY Retry 1 ButCANCEL Cancel 0} But$defb {} [my PrepArgs $args]] }



seek_highlight [::apave::APaveDialog]APaveDialog, Top

Seeks the selected word forward/backward/to first/to last in a text.

OBJECT seek_highlight txt mode
Parameters
txtNot documented.
mode0 (search backward), 1 (forward), 2 (first), 3 (last)
wpath to the text

method seek_highlight {txt mode} { # Seeks the selected word forward/backward/to first/to last in a text. # w - path to the text # mode - 0 (search backward), 1 (forward), 2 (first), 3 (last) my unhighlight_matches $txt lassign [my get_highlighted $txt] sel pos pos2 if {!$pos} return my set_HighlightedString $sel switch $mode { 0 { ;# backward set nc [expr {[string length $sel] - 1}] set pos [$txt index "$pos - $nc chars"] set pos [$txt search -backwards -- $sel $pos 1.0] } 1 { ;# forward set pos [$txt search -- $sel $pos2 end] } 2 { ;# to first set pos [$txt search -- $sel 1.0 end] } 3 { ;# to last set pos [$txt search -backwards -- $sel end 1.0] } } if {[string length "$pos"]} { ::tk::TextSetCursor $txt $pos $txt tag add sel $pos [$txt index "$pos + [string length $sel] chars"] } }



selectedWordText [::apave::APaveDialog]APaveDialog, Top

Returns a word under the cursor or a selected text.

OBJECT selectedWordText txt
Parameters
txtthe text's path
Return value

Returns a word under the cursor or a selected text.


method selectedWordText {txt} { # Returns a word under the cursor or a selected text. # txt - the text's path set seltxt {} if {![catch {$txt tag ranges sel} seltxt]} { if {[set forword [expr {$seltxt eq {}}]]} { set pos [$txt index "insert wordstart"] set pos2 [$txt index "insert wordend"] set seltxt [string trim [$txt get $pos $pos2]] if {![string is wordchar -strict $seltxt]} { # when cursor just at the right of word: take the word at the left set pos [$txt index "insert -1 char wordstart"] set pos2 [$txt index "insert -1 char wordend"] } } else { lassign $seltxt pos pos2 } catch { set seltxt [$txt get $pos $pos2] if {[set sttrim [string trim $seltxt]] ne {}} { if {$forword} {set seltxt $sttrim} } } } return $seltxt }



set_highlight_matches [::apave::APaveDialog]APaveDialog, Top

Creates bindings to highlight matches in a text.

OBJECT set_highlight_matches w
Parameters
wpath to the text

method set_highlight_matches {w} { # Creates bindings to highlight matches in a text. # w - path to the text if {![winfo exists $w]} return $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] ::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] { bind $w <$k> [list [self] seek_highlight $w 2] } foreach k [::apave::getTextHotkeys AltW] { bind $w <$k> [list [self] seek_highlight $w 3] } }



set_HighlightedString [::apave::APaveDialog]APaveDialog, Top

Saves a string got from highlighting by Alt+left/right/q/w.

OBJECT set_HighlightedString sel
Parameters
selthe string to be saved

method set_HighlightedString {sel} { # Saves a string got from highlighting by Alt+left/right/q/w. # sel - the string to be saved set _pdg(hlstring) $sel if {[info exist ${_pdg(ns)}PD::fnd] && $sel ne {}} { set ${_pdg(ns)}PD::fnd $sel } }



unhighlight_matches [::apave::APaveDialog]APaveDialog, Top

Unhighlights matches of selected word in a text.

OBJECT unhighlight_matches txt
Parameters
txtNot documented.
wpath to the text

method unhighlight_matches {txt} { # Unhighlights matches of selected word in a text. # w - path to the text if {[info exists ::apave::_AP_VARS(HILI,$txt)] && $::apave::_AP_VARS(HILI,$txt)} { $txt tag remove hilited 1.0 end $txt tag remove hilited2 1.0 end set ::apave::_AP_VARS(HILI,$txt) no } }



yesno [::apave::APaveDialog]APaveDialog, Top

Shows the YESNO dialog.

OBJECT yesno icon ttl msg ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
defbbutton to be selected; optional, default YES
argsoptions

method yesno {icon ttl msg {defb YES} args} { # Shows the *YESNO* dialog. # icon - icon # ttl - title # msg - message # defb - button to be selected # args - options return [my Query $icon $ttl $msg {ButYES Yes 1 ButNO No 0} But$defb {} [my PrepArgs $args]] }



yesnocancel [::apave::APaveDialog]APaveDialog, Top

Shows the YESNOCANCEL dialog.

OBJECT yesnocancel icon ttl msg ?defb? ?args?
Parameters
iconicon
ttltitle
msgmessage
defbbutton to be selected; optional, default YES
argsoptions

method yesnocancel {icon ttl msg {defb YES} args} { # Shows the *YESNOCANCEL* dialog. # icon - icon # ttl - title # msg - message # defb - button to be selected # args - options return [my Query $icon $ttl $msg {ButYES Yes 1 ButNO No 2 ButCANCEL Cancel 0} But$defb {} [my PrepArgs $args]] }



APaveInput [::apave]apave, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
abortretrycancelSee APaveDialog.abortretrycancel
apaveThemeSee ObjectTheming.apaveTheme
basicDefFontSee ObjectTheming.basicDefFont
basicFontSizeSee ObjectTheming.basicFontSize
basicSmallFontSee ObjectTheming.basicSmallFont
basicTextFontSee ObjectTheming.basicTextFont
boldDefFontSee ObjectTheming.boldDefFont
boldTextFontSee ObjectTheming.boldTextFont
checkTimeoutButtonSee APave.checkTimeoutButton
checkXYSee APave.checkXY
chooserSee APave.chooser
colorChooserSee APave.colorChooser
colorWindowSee APave.colorWindow
configureSee APave.configure
create_FontsSee ObjectTheming.create_Fonts
create_FontsTypeSee ObjectTheming.create_FontsType
csAddSee ObjectTheming.csAdd
csCurrentSee ObjectTheming.csCurrent
csDarkSee ObjectTheming.csDark
csDeleteExternalSee ObjectTheming.csDeleteExternal
csExportSee ObjectTheming.csExport
csFontSee ObjectTheming.csFont
csFontDefSee ObjectTheming.csFontDef
csFontMonoSee ObjectTheming.csFontMono
csGetSee ObjectTheming.csGet
csGetNameSee ObjectTheming.csGetName
csMainColorsSee ObjectTheming.csMainColors
csMapThemeSee ObjectTheming.csMapTheme
csSetSee ObjectTheming.csSet
csTonedSee ObjectTheming.csToned
dateChooserSee APave.dateChooser
defaultAttrsSee APave.defaultAttrs
deleteLineSee APaveDialog.deleteLine
displayTaggedTextSee APave.displayTaggedText
displayTextSee APave.displayText
doubleTextSee APaveDialog.doubleText
editfileEdits or views a file with a set of main colors
fillGutterSee APave.fillGutter
findInTextSee APaveDialog.findInText
findWidPathSee APave.findWidPath
focusNextSee APave.focusNext
fontChooserSee APave.fontChooser
get_highlightedSee APaveDialog.get_highlighted
get_HighlightedStringSee APaveDialog.get_HighlightedString
getPropertySee ObjectProperty.getProperty
getTextContentSee APave.getTextContent
getWidChildrenSee APave.getWidChildren
highlight_matchesSee APaveDialog.highlight_matches
iconASee APave.iconA
initInputInitializes input and clears variables made in previous session.
initLinkFontSee APave.initLinkFont
initTooltipSee ObjectTheming.initTooltip
inputMakes and runs an input dialog.
labelFlashingSee APave.labelFlashing
leadingSpacesSee APave.leadingSpaces
linesMoveSee APaveDialog.linesMove
makeLabelLinkedSee APave.makeLabelLinked
makePopupSee APave.makePopup
makeWindowSee APave.makeWindow
miscSee APaveDialog.misc
okSee APaveDialog.ok
okcancelSee APaveDialog.okcancel
onKeyTextMSee APave.onKeyTextM
optionCascadeTextSee APave.optionCascadeText
ownWNameSee APave.ownWName
parentWNameSee APave.parentWName
pasteTextSee APaveDialog.pasteText
paveoptionValueSee APave.paveoptionValue
paveWindowSee APave.paveWindow
popupBlockCommandsSee APaveDialog.popupBlockCommands
popupFindCommandsSee APaveDialog.popupFindCommands
popupHighlightCommandsSee APaveDialog.popupHighlightCommands
progress_BeginSee APaveDialog.progress_Begin
progress_EndSee APaveDialog.progress_End
progress_GoSee APaveDialog.progress_Go
readonlyWidgetSee APave.readonlyWidget
resSee APave.res
resetTextSee APave.resetText
retrycancelSee APaveDialog.retrycancel
scrolledFrameSee APave.scrolledFrame
seek_highlightSee APaveDialog.seek_highlight
selectedWordTextSee APaveDialog.selectedWordText
set_highlight_matchesSee APaveDialog.set_highlight_matches
set_HighlightedStringSee APaveDialog.set_HighlightedString
setPropertySee ObjectProperty.setProperty
setTextBindsSee APave.setTextBinds
showModalSee APave.showModal
showWindowSee APave.showWindow
textLinkSee APave.textLink
themeExternalSee ObjectTheming.themeExternal
themeMandatorySee ObjectTheming.themeMandatory
themeNonThemedSee ObjectTheming.themeNonThemed
themePopupSee ObjectTheming.themePopup
themeWindowSee ObjectTheming.themeWindow
timeoutButtonSee APave.timeoutButton
tk_optionCascadeSee APave.tk_optionCascade
unhighlight_matchesSee APaveDialog.unhighlight_matches
untouchWidgetsSee ObjectTheming.untouchWidgets
validateColorChoiceSee APave.validateColorChoice
valueInputGets input variables' values.
varInputGets variables made and filled in a previous session as a list of "varname varvalue" pairs where varname is of form: namespace::var$widgetname.
vieweditFileViews or edits a file.
widgetTypeSee APave.widgetType
windowSee APave.window
yesnoSee APaveDialog.yesno
yesnocancelSee APaveDialog.yesnocancel
Superclasses

APaveDialog



constructor [::apave::APaveInput]APaveInput, Top

Creates APaveInput object.

APaveInput create ?args?
Parameters
argsadditional arguments
winwindow's name (path)

method constructor {args} { # Creates APaveInput object. # win - window's name (path) # args - additional arguments set _savedvv [list] if {[llength [self next]]} { next {*}$args } }



destructor [::apave::APaveInput]APaveInput, Top

Clears variables used in the object.

OBJECT destroy

method destructor {} { # Clears variables used in the object. my initInput unset _savedvv if {[llength [self next]]} next }



editfile [::apave::APaveInput]APaveInput, Top

Edits or views a file with a set of main colors

OBJECT editfile fname fg bg cc ?prepost? ?args?
Parameters
fnamename of file
fgforeground color of text widget
bgbackground color of text widget
cccaret's color of text widget
preposta command performing before and after creating a dialog; optional, default ""
argsadditional options (-readonly 1 for viewing the file).
Description

If fg isn't empty, all three colors are used to color a text.

See also

aplsimple.github.io


method editfile {fname fg bg cc {prepost {}} args} { # Edits or views a file with a set of main colors # fname - name of file # fg - foreground color of text widget # bg - background color of text widget # cc - caret's color of text widget # prepost - a command performing before and after creating a dialog # args - additional options (`-readonly 1` for viewing the file). # # If *fg* isn't empty, all three colors are used to color a text. # # See also: # [aplsimple.github.io](https://aplsimple.github.io/en/tcl/pave/index.html) if {$fname eq ""} { return false } set newfile 0 if {[catch {set filetxt [::apave::readTextFile $fname "" yes]}]} { return false } lassign [::apave::parseOptions $args -rotext "" -readonly 1 -ro 1] rotext readonly ro set btns "Exit 0" ;# by default 'view' mode set oper VIEW if {$rotext eq "" || !$readonly || !$ro} { set btns "Save 1 Cancel 0" set oper EDIT } if {$fg eq ""} { set tclr "" } else { set tclr "-fg $fg -bg $bg -cc $cc" } if {$prepost eq ""} {set aa ""} {set aa [$prepost filetxt]} set res [my misc "" "$oper FILE: $fname" "$filetxt" $btns TEXT -text 1 -w {100 80} -h 32 {*}$tclr -post $prepost {*}$aa {*}$args] set data [string range $res 2 end] if {[set res [string index $res 0]] eq "1"} { set data [string range $data [string first " " $data]+1 end] set data [string trimright $data] set res [::apave::writeTextFile $fname data] } elseif {$newfile} { file delete $fname } return $res }



initInput [::apave::APaveInput]APaveInput, Top

Initializes input and clears variables made in previous session.

OBJECT initInput

method initInput {} { # Initializes input and clears variables made in previous session. foreach {vn vv} $_savedvv { catch {unset $vn} } set _savedvv [list] set _pav(widgetopts) [list] return }



input [::apave::APaveInput]APaveInput, Top

Makes and runs an input dialog.

OBJECT input icon ttl iopts ?args?
Parameters
iconicon (omitted if equals to "")
ttltitle of window
ioptslist of widgets and their attributes
argslist of dialog's attributes
Description

The iopts contains lists of three items:

namename of widgets
promptprompt for entering data
valoptsvalue options

The valopts is a list specific for a widget's type, however a first item of valopts is always an initial input value.


method input {icon ttl iopts args} { # Makes and runs an input dialog. # icon - icon (omitted if equals to "") # ttl - title of window # iopts - list of widgets and their attributes # args - list of dialog's attributes # # The `iopts` contains lists of three items: # name - name of widgets # prompt - prompt for entering data # valopts - value options # # The `valopts` is a list specific for a widget's type, however # a first item of `valopts` is always an initial input value. if {$iopts ne {}} { my initInput ;# clear away all internal vars } set pady "-pady 2" if {[set focusopt [::apave::getOption -focus {*}$args]] ne ""} { set focusopt "-focus $focusopt" } lappend inopts [list fraM + T 1 98 "-st nsew $pady -rw 1"] set savedvv [list] set frameprev "" foreach {name prompt valopts} $iopts { if {$name eq ""} continue lassign $prompt prompt gopts attrs set gopts "$pady $gopts" set typ [string tolower [string range $name 0 1]] if {$typ eq "v_" || $typ eq "se"} { lappend inopts [list fraM.$name - - - - "pack -fill x $gopts"] continue } set toprev [::apave::getOption -toprev {*}$attrs] set attrs [::apave::removeOptions $attrs -toprev] set tvar "-tvar" switch -exact -- $typ { ch { set tvar "-var" } sp { set gopts "$gopts -expand 0 -side left"} } set framename fraM.fra$name if {$typ in {lb te tb}} { ;# the widgets sized vertically lappend inopts [list $framename - - - - "pack -expand 1 -fill both"] } else { lappend inopts [list $framename - - - - "pack -fill x"] } set vv [my VarName $name] set ff [my FieldName $name] if {$typ ne "la" && $toprev eq ""} { set takfoc [::apave::parseOptions $attrs -takefocus 1] if {$focusopt eq "" && $takfoc} { if {$typ in {fi di cl fo da}} { set _ en*$name ;# 'entry-like mega-widgets' } elseif {$typ eq "ft"} { set _ te*$name ;# ftx - 'text-like mega-widget' } else { set _ $name } set focusopt "-focus $_" } if {$typ in {lb tb te}} {set anc nw} {set anc w} lappend inopts [list fraM.fra$name.labB$name - - - - "pack -side left -anchor $anc -padx 3" "-t \"$prompt\" -font \"-family {[my basicTextFont]} -size [my basicFontSize]\""] } # for most widgets: # 1st item of 'valopts' list is the current value # 2nd and the rest of 'valopts' are a list of values if {$typ ni {fc te la}} { # curr.value can be set with a variable, so 'subst' is applied set vsel [lindex $valopts 0] catch {set vsel [subst -nocommands -nobackslashes $vsel]} set vlist [lrange $valopts 1 end] } if {[set msgLab [::apave::getOption -msgLab {*}$attrs]] ne ""} { set attrs [::apave::removeOptions $attrs -msgLab] } # define a current widget's info switch -exact -- $typ { lb - tb { set $vv $vlist lappend attrs -lvar $vv if {$vsel ni {"" "-"}} { lappend attrs -lbxsel "$::apave::UFF$vsel$::apave::UFF" } lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill both $gopts" $attrs] lappend inopts [list fraM.fra$name.sbv$name $ff L - - "pack -fill y"] } cb { if {![info exist $vv]} {catch {set $vv ""}} lappend attrs -tvar $vv -values $vlist if {$vsel ni {"" "-"}} { lappend attrs -cbxsel "$::apave::UFF$vsel$::apave::UFF" } lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill x $gopts" $attrs] } fc { if {![info exist $vv]} {catch {set $vv ""}} lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill x $gopts" "-tvar $vv -values \{$valopts\} $attrs"] } op { set $vv $vsel lappend inopts [list $ff - - - - "pack -fill x $gopts" "$vv $vlist"] } ra { if {![info exist $vv]} {catch {set $vv $vsel}} set padx 0 foreach vo $vlist { set name $name lappend inopts [list $ff[incr nnn] - - - - "pack -side left $gopts -padx $padx" "-var $vv -value \"$vo\" -t \"$vo\" $attrs"] set padx [expr {$padx ? 0 : 9}] } } te { if {![info exist $vv]} {set $vv [string map {\\n \n \\t \t} $valopts]} if {[dict exist $attrs -state] && [dict get $attrs -state] eq "disabled"} { # disabled text widget cannot be filled with a text, so we should # compensate this through a home-made attribute (-disabledtext) set disattr "-disabledtext \{[set $vv]\}" } elseif {[dict exist $attrs -readonly] && [dict get $attrs -readonly] || [dict exist $attrs -ro] && [dict get $attrs -ro]} { set disattr "-rotext \{[set $vv]\}" set attrs [::apave::removeOptions $attrs -readonly -ro] } else { set disattr "" } lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill both $gopts" "$attrs $disattr"] lappend inopts [list fraM.fra$name.sbv$name $ff L - - "pack -fill y"] } la { if {$prompt ne ""} { set prompt "-t \"$prompt\" " } ;# prompt as -text lappend inopts [list $ff - - - - "pack -anchor w $gopts" "$prompt$attrs"] continue } bu - ch { set prompt "" if {$toprev eq ""} { lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill both $gopts" "$tvar $vv $attrs"] } else { lappend inopts [list $frameprev.$name - - - - "pack -side left $gopts" "$tvar $vv $attrs"] } if {$vv ne ""} { if {![info exist $vv]} { catch { if {$vsel eq ""} {set vsel 0} set $vv $vsel } } } } default { lappend inopts [list $ff - - - - "pack -side left -expand 1 -fill x $gopts" "$tvar $vv $attrs"] if {$vv ne ""} { if {![info exist $vv]} {catch {set $vv $vsel}} } } } if {$msgLab ne ""} { lassign $msgLab lab msg set lab [my parentWName [lindex $inopts end 0]].$lab if {$msg ne ""} {set msg "-t {$msg}"} lappend inopts [list $lab - - - - "pack -side left -expand 1 -fill x" $msg] } if {![info exist $vv]} {set $vv ""} lappend _savedvv $vv [set $vv] set frameprev $framename } lassign [::apave::parseOptions $args -titleOK OK -titleCANCEL Cancel -centerme ""] titleOK titleCANCEL centerme if {$titleCANCEL eq ""} { set butCancel "" } else { set butCancel "butCANCEL $titleCANCEL 0" } if {$centerme eq ""} { set centerme "-centerme 1" } else { set centerme "-centerme $centerme" } set args [::apave::removeOptions $args -titleOK -titleCANCEL -centerme] lappend args {*}$focusopt if {[catch { set res [my Query $icon $ttl {} "butOK $titleOK 1 $butCancel" butOK $inopts [my PrepArgs $args] "" {*}$centerme]} e]} { catch {destroy $_pdg(dlg)} ;# Query's window ::apave::obj ok err "ERROR" "\n$e\n" -t 1 -head "\nAPaveInput returned an error: \n" -hfg red -weight bold return 0 } if {![lindex $res 0]} { ;# restore old values if OK not chosen foreach {vn vv} $_savedvv { # tk_optionCascade (destroyed now) was tracing its variable => catch catch {set $vn $vv} } } return $res }



valueInput [::apave::APaveInput]APaveInput, Top

Gets input variables' values.

OBJECT valueInput

method valueInput {} { # Gets input variables' values. set _values {} foreach {vnam -} [my varInput] { lappend _values [set $vnam] } return $_values }



varInput [::apave::APaveInput]APaveInput, Top

Gets variables made and filled in a previous session as a list of "varname varvalue" pairs where varname is of form: namespace::var$widgetname.

OBJECT varInput

method varInput {} { # Gets variables made and filled in a previous session # as a list of "varname varvalue" pairs where varname # is of form: namespace::var$widgetname. return $_savedvv }



vieweditFile [::apave::APaveInput]APaveInput, Top

Views or edits a file.

OBJECT vieweditFile fname ?prepost? ?args?
Parameters
fnamename of file
preposta command performing before and after creating a dialog; optional, default ""
argsadditional options
Description

It's a sort of stub for calling editfile method.

See also

editfile


method vieweditFile {fname {prepost {}} args} { # Views or edits a file. # fname - name of file # prepost - a command performing before and after creating a dialog # args - additional options # It's a sort of stub for calling *editfile* method. # See also: editfile return [my editfile $fname "" "" "" $prepost {*}$args] }



ObjectProperty [::apave]apave, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
getPropertyGets an property's value as "object-wide".
setPropertySets a property's value as "object-wide".
Subclasses

ObjectTheming



constructor [::apave::ObjectProperty]ObjectProperty, Top

ObjectProperty create ?args?
Parameters
argsOptional arguments.

method constructor {args} { array set _OP_Properties {} # ObjectProperty can play solo or be a mixin if {[llength [self next]]} { next {*}$args } }



destructor [::apave::ObjectProperty]ObjectProperty, Top

OBJECT destroy

method destructor {} { array unset _OP_Properties if {[llength [self next]]} next }



getProperty [::apave::ObjectProperty]ObjectProperty, Top

Gets an property's value as "object-wide".

OBJECT getProperty name ?defvalue?
Parameters
namename of property
defvaluedefault value; optional, default ""
Description

If the property had been set, the method returns its value.

Otherwise, the method returns the default value ($defvalue).


method getProperty {name {defvalue {}}} { # Gets an property's value as "object-wide". # name - name of property # defvalue - default value # # If the property had been set, the method returns its value. # # Otherwise, the method returns the default value (`$defvalue`). if {[info exists _OP_Properties($name)]} { return $_OP_Properties($name) } return $defvalue }



setProperty [::apave::ObjectProperty]ObjectProperty, Top

Sets a property's value as "object-wide".

OBJECT setProperty name ?args?
Parameters
namename of property
argsvalue of property
Description

If args is omitted, the method returns a property's value.

If args is set, the method sets a property's value as $args.


method setProperty {name args} { # Sets a property's value as "object-wide". # name - name of property # args - value of property # # If *args* is omitted, the method returns a property's value. # # If *args* is set, the method sets a property's value as $args. switch -exact [llength $args] { 0 {return [my getProperty $name]} 1 {return [set _OP_Properties($name) [lindex $args 0]]} } puts -nonewline stderr "Wrong # args: should be \"[namespace current] setProperty propertyname ?value?\"" return -code error }



ObjectTheming [::apave]apave, Top

Method summary
constructorConstructor for the class.
destructorDestructor for the class.
apaveThemeChecks if apave color scheme is used (always for standard ttk themes).
basicDefFontGets/Sets a basic default font.
basicFontSizeGets/Sets a basic size of font used in apave
basicSmallFontGets/Sets a basic small font used in status bar etc.
basicTextFontGets/Sets a basic font used in editing/viewing text widget.
boldDefFontReturns a bold default font.
boldTextFontReturns a bold fixed font.
create_FontsCreates fonts used in apave.
create_FontsTypeCreates fonts used in apave, with additional options.
csAddRegisters new color scheme in the list of CS.
csCurrentGets an index of current color scheme
csDarkReturns a flag "a color scheme is dark"
csDeleteExternalRemoves all external CS.
csExportTODO
csFontReturns attributes of CS font.
csFontDefReturns attributes of CS default font.
csFontMonoReturns attributes of CS monotype font.
csGetGets a color scheme's colors
csGetNameGets a color scheme's name
csMainColorsReturns a list of main colors' indices of CS.
csMapThemeReturns a map of CS / themeWindow method colors.
csSetSets a color scheme and applies it to Tk/Ttk widgets.
csTonedMake an external CS that has tones (hues) of colors for a CS.
getPropertySee ObjectProperty.getProperty
initTooltipConfigurates colors and other attributes of tooltip.
setPropertySee ObjectProperty.setProperty
themeExternalConfigures an external dialogue so that its colors accord with a current CS.
themeMandatoryThemes all that must be themed.
themeNonThemedUpdates the appearances of currently used widgets (non-themed).
themePopupConfigures a popup menu so that its colors accord with a current CS.
themeWindowChanges a Tk style (theming a bit)
untouchWidgetsMakes non-ttk widgets to be untouched by coloring or gets their list.
Mixins

ObjectProperty

Subclasses

APave



constructor [::apave::ObjectTheming]ObjectTheming, Top

ObjectTheming create ?args?
Parameters
argsOptional arguments.

method constructor {args} { my InitCS # ObjectTheming can play solo or be a mixin if {[llength [self next]]} { next {*}$args } }



destructor [::apave::ObjectTheming]ObjectTheming, Top

OBJECT destroy

method destructor {} { if {[llength [self next]]} next }



apaveTheme [::apave::ObjectTheming]ObjectTheming, Top

Checks if apave color scheme is used (always for standard ttk themes).

OBJECT apaveTheme ?theme?
Parameters
themea theme to be checked (if omitted, a current ttk theme); optional, default ""

method apaveTheme {{theme {}}} { # Checks if apave color scheme is used (always for standard ttk themes). # theme - a theme to be checked (if omitted, a current ttk theme) if {$theme eq {}} {set theme [ttk::style theme use]} return [expr {$theme in {clam alt classic default awdark awlight}}] }



basicDefFont [::apave::ObjectTheming]ObjectTheming, Top

Gets/Sets a basic default font.

OBJECT basicDefFont ?deffont?
Parameters
deffontfont; optional, default ""
Description

If 'deffont' is omitted or =="", this method gets it. If 'deffont' is set, this method sets it.


method basicDefFont {{deffont {}}} { # Gets/Sets a basic default font. # deffont - font # # If 'deffont' is omitted or =="", this method gets it. # If 'deffont' is set, this method sets it. if {$deffont ne ""} { return [set ::apave::_CS_(defFont) $deffont] } else { return $::apave::_CS_(defFont) } }



basicFontSize [::apave::ObjectTheming]ObjectTheming, Top

Gets/Sets a basic size of font used in apave

OBJECT basicFontSize ?fs? ?ds?
Parameters
fsfont size; optional, default 0
dsincr/decr of size; optional, default 0
Description

If 'fs' is omitted or ==0, this method gets it. If 'fs' >0, this method sets it.


method basicFontSize {{fs 0} {ds 0}} { # Gets/Sets a basic size of font used in apave # fs - font size # ds - incr/decr of size # # If 'fs' is omitted or ==0, this method gets it. # If 'fs' >0, this method sets it. if {$fs} { set ::apave::_CS_(fs) [expr {$fs + $ds}] my create_Fonts return $::apave::_CS_(fs) } else { return [expr {$::apave::_CS_(fs) + $ds}] } }



basicSmallFont [::apave::ObjectTheming]ObjectTheming, Top

Gets/Sets a basic small font used in status bar etc.

OBJECT basicSmallFont ?smallfont?
Parameters
smallfontfont; optional, default ""
Description

If 'smallfont' is omitted or =="", this method gets it. If 'smallfont' is set, this method sets it.


method basicSmallFont {{smallfont {}}} { # Gets/Sets a basic small font used in status bar etc. # smallfont - font # # If 'smallfont' is omitted or =="", this method gets it. # If 'smallfont' is set, this method sets it. if {$smallfont ne ""} { return [set ::apave::_CS_(smallFont) $smallfont] } else { return $::apave::_CS_(smallFont) } }



basicTextFont [::apave::ObjectTheming]ObjectTheming, Top

Gets/Sets a basic font used in editing/viewing text widget.

OBJECT basicTextFont ?textfont?
Parameters
textfontfont; optional, default ""
Description

If 'textfont' is omitted or =="", this method gets it. If 'textfont' is set, this method sets it.


method basicTextFont {{textfont {}}} { # Gets/Sets a basic font used in editing/viewing text widget. # textfont - font # # If 'textfont' is omitted or =="", this method gets it. # If 'textfont' is set, this method sets it. if {$textfont ne ""} { return [set ::apave::_CS_(textFont) $textfont] } else { return $::apave::_CS_(textFont) } }



boldDefFont [::apave::ObjectTheming]ObjectTheming, Top

Returns a bold default font.

OBJECT boldDefFont ?fs?
Parameters
fsfont size; optional, default 0
Return value

Returns a bold default font.


method boldDefFont {{fs 0}} { # Returns a bold default font. # fs - font size if {$fs == 0} {set fs [my basicFontSize]} set bf [font actual basicDefFont] return [dict replace $bf -family [my basicDefFont] -weight bold -size $fs] }



boldTextFont [::apave::ObjectTheming]ObjectTheming, Top

Returns a bold fixed font.

OBJECT boldTextFont ?fs?
Parameters
fsfont size; optional, default 0
Return value

Returns a bold fixed font.


method boldTextFont {{fs 0}} { # Returns a bold fixed font. # fs - font size if {$fs == 0} {set fs [expr {2+[my basicFontSize]}]} set bf [font actual TkFixedFont] return [dict replace $bf -family [my basicTextFont] -weight bold -size $fs] }



create_Fonts [::apave::ObjectTheming]ObjectTheming, Top

Creates fonts used in apave.

OBJECT create_Fonts

method create_Fonts {} { # Creates fonts used in apave. catch {font delete apaveFontMono} catch {font delete apaveFontDef} catch {font delete apaveFontMonoBold} catch {font delete apaveFontDefBold} font create apaveFontMono -family $::apave::_CS_(textFont) -size $::apave::_CS_(fs) font create apaveFontDef -family $::apave::_CS_(defFont) -size $::apave::_CS_(fs) font create apaveFontMonoBold {*}[my boldTextFont] font create apaveFontDefBold {*}[my boldDefFont] set ::apave::FONTMAIN "[font actual apaveFontDef]" set ::apave::FONTMAINBOLD "[font actual apaveFontDefBold]" }



create_FontsType [::apave::ObjectTheming]ObjectTheming, Top

Creates fonts used in apave, with additional options.

OBJECT create_FontsType type ?args?
Parameters
typetype of the created fonts
argspairs "option value"
Return value

Returns a list of two created font names (default & mono).


method create_FontsType {type args} { # Creates fonts used in apave, with additional options. # type - type of the created fonts # args - pairs "option value" # Returns a list of two created font names (default & mono). set name1 apaveFontDefTyped$type set name2 apaveFontMonoTyped$type catch {font delete $name1} catch {font delete $name2} font create $name1 -family $::apave::_CS_(defFont) -size $::apave::_CS_(fs) {*}$args font create $name2 -family $::apave::_CS_(textFont) -size $::apave::_CS_(fs) {*}$args return [list $name1 $name2] }



csAdd [::apave::ObjectTheming]ObjectTheming, Top

Registers new color scheme in the list of CS.

OBJECT csAdd newcs ?setnew?
Parameters
newcsCS item
setnewif true, sets the CS as current; optional, default true
Description

Does not register the CS, if it is already registered.

Return value

Returns an index of current CS.

See also

themeWindow


method csAdd {newcs {setnew true}} { # Registers new color scheme in the list of CS. # newcs - CS item # setnew - if true, sets the CS as current # # Does not register the CS, if it is already registered. # # Returns an index of current CS. # # See also: # themeWindow if {[llength $newcs]<4} { set newcs [my ColorScheme] ;# CS should be defined } lassign $newcs name tfg2 tfg1 tbg2 tbg1 tfhh - - tcur grey bclr set found $::apave::_CS_(NONCS) set maxcs [::apave::cs_Max] for {set i $::apave::_CS_(MINCS)} {$i<=$maxcs} {incr i} { lassign [my csGet $i] cfg2 cfg1 cbg2 cbg1 cfhh - - ccur if {$cfg2 eq $tfg2 && $cfg1 eq $tfg1 && $cbg2 eq $tbg2 && $cbg1 eq $tbg1 && $cfhh eq $tfhh && $ccur eq $tcur} { set found $i break } } if {$found == $::apave::_CS_(MINCS) && [my csCurrent] == $::apave::_CS_(NONCS)} { set setnew false ;# no moves from default CS to 'basic' } elseif {$found == $::apave::_CS_(NONCS)} { lappend ::apave::_CS_(ALL) $newcs set found [expr {$maxcs+1}] } if {$setnew} {set ::apave::_CS_(index) [set ::apave::_CS_(old) $found]} return [my csCurrent] }



csCurrent [::apave::ObjectTheming]ObjectTheming, Top

Gets an index of current color scheme

OBJECT csCurrent

method csCurrent {} { # Gets an index of current color scheme return $::apave::_CS_(index) }



csDark [::apave::ObjectTheming]ObjectTheming, Top

Returns a flag "a color scheme is dark"

OBJECT csDark ?cs?
Parameters
csthe color scheme to be checked (the current one, if not set); optional, default ""
Return value

Returns a flag "a color scheme is dark"


method csDark {{cs {}}} { # Returns a flag "a color scheme is dark" # cs - the color scheme to be checked (the current one, if not set) if {$cs eq {} || $cs==-3} {set cs [my csCurrent]} lassign $::apave::_CS_(TONED) csbasic cstoned if {$cs==$cstoned} {set cs $csbasic} return [expr {$cs>22}] }



csDeleteExternal [::apave::ObjectTheming]ObjectTheming, Top

Removes all external CS.

OBJECT csDeleteExternal

method csDeleteExternal {} { # Removes all external CS. set ::apave::_CS_(ALL) [lreplace $::apave::_CS_(ALL) 48 end] }



csExport [::apave::ObjectTheming]ObjectTheming, Top

TODO

OBJECT csExport

method csExport {} { # TODO set theme "" foreach arg {tfg1 tbg1 tfg2 tbg2 tfgS tbgS tfgD tbgD tcur bclr args} { if {[catch {set a "$::apave::_CS_(expo,$arg)"}] || $a==""} { break } append theme " $a" } return $theme }



csFont [::apave::ObjectTheming]ObjectTheming, Top

Returns attributes of CS font.

OBJECT csFont fontname
Parameters
fontnameNot documented.
Return value

Returns attributes of CS font.


method csFont {fontname} { # Returns attributes of CS font. if {[catch {set font [font configure $fontname]}]} { my create_Fonts set font [font configure $fontname] } return $font }



csFontDef [::apave::ObjectTheming]ObjectTheming, Top

Returns attributes of CS default font.

OBJECT csFontDef
Return value

Returns attributes of CS default font.


method csFontDef {} { # Returns attributes of CS default font. return [my csFont apaveFontDef] }



csFontMono [::apave::ObjectTheming]ObjectTheming, Top

Returns attributes of CS monotype font.

OBJECT csFontMono
Return value

Returns attributes of CS monotype font.


method csFontMono {} { # Returns attributes of CS monotype font. return [my csFont apaveFontMono] }



csGet [::apave::ObjectTheming]ObjectTheming, Top

Gets a color scheme's colors

OBJECT csGet ?ncolor?
Parameters
ncolorindex of color scheme; optional, default ""

method csGet {{ncolor {}}} { # Gets a color scheme's colors # ncolor - index of color scheme if {$ncolor eq ""} {set ncolor [my csCurrent]} return [lrange [my ColorScheme $ncolor] 1 end] }



csGetName [::apave::ObjectTheming]ObjectTheming, Top

Gets a color scheme's name

OBJECT csGetName ?ncolor?
Parameters
ncolorindex of color scheme; optional, default 0

method csGetName {{ncolor 0}} { # Gets a color scheme's name # ncolor - index of color scheme if {$ncolor < $::apave::_CS_(MINCS)} { return "-2: None" } elseif {$ncolor == $::apave::_CS_(MINCS)} { return "-1: Basic" } return [lindex [my ColorScheme $ncolor] 0] }



csMainColors [::apave::ObjectTheming]ObjectTheming, Top

Returns a list of main colors' indices of CS.

OBJECT csMainColors
Return value

Returns a list of main colors' indices of CS.

See also

csMapTheme


method csMainColors {} { # Returns a list of main colors' indices of CS. # See also: csMapTheme return [list 0 1 2 3 5 10 11 13 16] }



csMapTheme [::apave::ObjectTheming]ObjectTheming, Top

Returns a map of CS / themeWindow method colors.

OBJECT csMapTheme
Description

The map is a list of indices in CS corresponding to themeWindow's args.

CS record is: 0-itemfg 1-mainfg 2-itembg 3-mainbg 4-itemsHL 5-actbg 6-actfg 7-cursor 8-greyed 9-hot 10-emfg 11-embg 12-- 13-menubg 14-winfg 15-winbg 16-itemHL2 ...reserved...

Return value

Returns a map of CS / themeWindow method colors.

See also

themeWindow


method csMapTheme {} { # Returns a map of CS / themeWindow method colors. # # The map is a list of indices in CS corresponding to themeWindow's args. # # CS record is: # 0-itemfg 1-mainfg 2-itembg 3-mainbg 4-itemsHL 5-actbg 6-actfg 7-cursor 8-greyed 9-hot 10-emfg 11-embg 12-- 13-menubg 14-winfg 15-winbg 16-itemHL2 ...reserved... # # See also: themeWindow return [list 1 3 0 2 6 5 8 3 7 9 4 10 11 1 13 14 15 16 17 18 19 20 21] }



csSet [::apave::ObjectTheming]ObjectTheming, Top

Sets a color scheme and applies it to Tk/Ttk widgets.

OBJECT csSet ?ncolor? ?win? ?args?
Parameters
ncolorindex of color scheme; optional, default 0
winwindow's name; optional, default .
argslist of colors if ncolor=""
Description

The args can be set as "-doit". In this case the method does set the ncolor color scheme (otherwise it doesn't set the CS if it's already of the same ncolor).


method csSet {{ncolor 0} {win .} args} { # Sets a color scheme and applies it to Tk/Ttk widgets. # ncolor - index of color scheme # win - window's name # args - list of colors if ncolor="" # # The `args` can be set as "-doit". In this case the method does set # the `ncolor` color scheme (otherwise it doesn't set the CS if it's # already of the same `ncolor`). # The clrtitf, clrinaf etc. had been designed for e_menu. And as such, # they can be used directly, outside of this "color scheming" UI. # They set pairs of related fb/bg: # clrtitf/clrtitb is item's fg/bg # clrinaf/clrinab is main fg/bg # clractf/clractb is active (selection) fg/bg # and separate colors: # clrhelp is "help" foreground # clrcurs is "caret" background # clrgrey is "shadowing" background # clrhotk is "hotkey/border" foreground # # In color scheming, these colors are transformed to be consistent # with Tk/Ttk's color mechanics. # # Additionally, "grey" color is used as "border color/disabled foreground". # # Returns a list of colors used by the color scheme. if {$ncolor == -2} { ttk::style map Treeview -foreground [list readonly grey disabled grey selected black] return {} } if {$ncolor eq {}} { lassign $args clrtitf clrinaf clrtitb clrinab clrhelp clractb clractf clrcurs clrgrey clrhotk tfgI tbgI fM bM tfgW tbgW tHL2 tbHL chkHL res5 res6 res7 } else { foreach cs [list $ncolor $::apave::_CS_(MINCS)] { lassign [my csGet $cs] clrtitf clrinaf clrtitb clrinab clrhelp clractb clractf clrcurs clrgrey clrhotk tfgI tbgI fM bM tfgW tbgW tHL2 tbHL chkHL res5 res6 res7 if {$clrtitf ne ""} break set ncolor $cs } set ::apave::_CS_(index) $ncolor } set fg $clrinaf ;# main foreground set bg $clrinab ;# main background set fE $clrtitf ;# fieldforeground foreground set bE $clrtitb ;# fieldforeground background set fS $clractf ;# active/selection foreground set bS $clractb ;# active/selection background set hh $clrhelp ;# (not used in cs' theming) title color set gr $clrgrey ;# (not used in cs' theming) shadowing color set cc $clrcurs ;# caret's color set ht $clrhotk ;# hotkey color set grey $gr ;# #808080 if {$::apave::_CS_(old) != $ncolor || $args eq "-doit"} { set ::apave::_CS_(old) $ncolor my themeWindow $win [list $fg $bg $fE $bE $fS $bS $grey $bg $cc $ht $hh $tfgI $tbgI $fM $bM $tfgW $tbgW $tHL2 $tbHL $chkHL $res5 $res6 $res7] my UpdateColors my initTooltip } set ::apave::FGMAIN $fg set ::apave::BGMAIN $bg catch { if {[my csDark $ncolor]} {::baltip::configure -relief groove} } return [list $fg $bg $fE $bE $fS $bS $hh $grey $cc $ht $tfgI $tbgI $fM $bM $tfgW $tbgW $tHL2 $tbHL $chkHL $res5 $res6 $res7] }



csToned [::apave::ObjectTheming]ObjectTheming, Top

Make an external CS that has tones (hues) of colors for a CS.

OBJECT csToned cs hue
Parameters
csinternal apave CS to be toned
huea percent to get light (> 0) or dark (< 0) tones
Description

This method allows only one external CS, eliminating others. Returns: "yes" if the CS was toned


method csToned {cs hue} { # Make an external CS that has tones (hues) of colors for a CS. # cs - internal apave CS to be toned # hue - a percent to get light (> 0) or dark (< 0) tones # This method allows only one external CS, eliminating others. # Returns: "yes" if the CS was toned if {$cs <= $::apave::_CS_(NONCS) || $cs > $::apave::_CS_(STDCS)} { return no } my csDeleteExternal set CS [my csGet $cs] set mainc [my csMainColors] set hue [expr {(100.0+$hue)/100.0}] foreach i [my csMapTheme] { set color [lindex $CS $i] if {$i in $mainc} { set color [string map {black #000000 white #ffffff grey #808080 red #ff0000 yellow #ffff00 orange #ffa500 #000 #000000 #fff #ffffff} $color] scan $color #%2x%2x%2x R G B foreach valname {R G B} { set val [expr {int([set $valname]*$hue)}] set $valname [expr {max(min($val,255),0)}] } set color [format #%02x%02x%02x $R $G $B] } lappend TWargs $color } my themeWindow . $TWargs no set ::apave::_CS_(TONED) [list $cs [my csCurrent]] return yes }



initTooltip [::apave::ObjectTheming]ObjectTheming, Top

Configurates colors and other attributes of tooltip.

OBJECT initTooltip ?args?
Parameters
argsoptions of ::baltip::configure

method initTooltip {args} { # Configurates colors and other attributes of tooltip. # args - options of ::baltip::configure lassign [lrange [my csGet] 14 15] fW bW ::baltip config -fg $fW -bg $bW -global yes ::baltip config {*}$args return }



themeExternal [::apave::ObjectTheming]ObjectTheming, Top

Configures an external dialogue so that its colors accord with a current CS.

OBJECT themeExternal ?args?
Parameters
argslist of untouched widgets

method themeExternal {args} { # Configures an external dialogue so that its colors accord with a current CS. # args - list of untouched widgets if {[set cs [my csCurrent]] != -2} { foreach untw $args {my untouchWidgets $untw} after idle [list [self] csSet $cs . -doit] ;# theme the dialogue to be run } }



themeMandatory [::apave::ObjectTheming]ObjectTheming, Top

Themes all that must be themed.

OBJECT themeMandatory win ?args?
Parameters
winwindow's name
argsoptions

method themeMandatory {win args} { # Themes all that must be themed. # win - window's name # args - options # set the new options for nested widgets (menu e.g.) my themeNonThemed $win # other options per widget type foreach {typ v1 v2} $args { if {$typ eq "-"} { # config of non-themed widgets set ind [incr ::apave::_C_($v1,0)] set ::apave::_C_($v1,$ind) "$v2" } else { # style maps of themed widgets my Ttk_style map $typ $v1 [list {*}$v2] } } ::apave::initStyles my ThemeChoosers return }



themeNonThemed [::apave::ObjectTheming]ObjectTheming, Top

Updates the appearances of currently used widgets (non-themed).

OBJECT themeNonThemed win ?addwid?
Parameters
winwindow path whose children will be touched
addwidadditional widget(s) to be touched; optional, default ""
See also

untouchWidgets


method themeNonThemed {win {addwid {}}} { # Updates the appearances of currently used widgets (non-themed). # win - window path whose children will be touched # addwid - additional widget(s) to be touched # # See also: # untouchWidgets set wtypes [my NonThemedWidgets all] set lwid [winfo children $win] lappend lwid {*}$addwid foreach w1 $lwid { my themeNonThemed $w1 set ts [string tolower [winfo class $w1]] set tch 1 foreach u $::apave::_CS_(untouch) { if {[string match $u $w1]} {set tch 0; break} } if {$tch && [info exist ::apave::_C_($ts,0)] && [lsearch -exact $wtypes $ts]>-1} { set i 0 while {[incr i] <= $::apave::_C_($ts,0)} { lassign $::apave::_C_($ts,$i) opt val catch { if {[string first __tooltip__.label $w1]<0} { $w1 configure $opt $val switch -exact -- [$w1 cget -state] { disabled { $w1 configure {*}[my NonTtkStyle $w1 1] } readonly { $w1 configure {*}[my NonTtkStyle $w1 2] } } } set nam3 [string range [my ownWName $w1] 0 2] if {$nam3 in {lbx tbl flb enT spX tex}} { my UpdateSelectAttrs $w1 } } } } } return }



themePopup [::apave::ObjectTheming]ObjectTheming, Top

Configures a popup menu so that its colors accord with a current CS.

OBJECT themePopup mnu
Parameters
mnumenu's name (path)

method themePopup {mnu} { # Configures a popup menu so that its colors accord with a current CS. # mnu - menu's name (path) if {[my csCurrent] == $::apave::_CS_(NONCS)} return lassign [my csGet] - fg - bg2 - bgS fgS - tfgD - - - - bg if {$bg eq {}} {set bg $bg2} set opts "-foreground $fg -background $bg -activeforeground $fgS -activebackground $bgS -font {[font actual apaveFontDef]}" if {[catch {my ThemePopup $mnu {*}$opts -disabledforeground $tfgD}]} { my ThemePopup $mnu {*}$opts } my themeNonThemed $mnu $mnu }



themeWindow [::apave::ObjectTheming]ObjectTheming, Top

Changes a Tk style (theming a bit)

OBJECT themeWindow win ?clrs? ?isCS? ?args?
Parameters
winwindow's name
clrslist of colors; optional, default ""
isCStrue, if the colors are taken from a CS; optional, default true
argsother options
Description

The clrs contains:

tfg1foreground for themed widgets (main stock)
tbg1background for themed widgets (main stock)
tfg2foreground for themed widgets (enter data stock)
tbg2background for themed widgets (enter data stock)
tfgSforeground for selection
tbgSbackground for selection
tfgDforeground for disabled themed widgets
tbgDbackground for disabled themed widgets
tcurinsertion cursor color
bclrhotkey/border color
thlphelp color
tfgIforeground for external CS
tbgIbackground for external CS
tfgMforeground for menus
tbgMbackground for menus

The themeWindow can be used outside of "color scheme" UI. E.g., in TKE editor, e_menu and add_shortcuts plugins use it to be consistent with TKE theme.


method themeWindow {win {clrs {}} {isCS true} args} { # Changes a Tk style (theming a bit) # win - window's name # clrs - list of colors # isCS - true, if the colors are taken from a CS # args - other options # # The clrs contains: # tfg1 - foreground for themed widgets (main stock) # tbg1 - background for themed widgets (main stock) # tfg2 - foreground for themed widgets (enter data stock) # tbg2 - background for themed widgets (enter data stock) # tfgS - foreground for selection # tbgS - background for selection # tfgD - foreground for disabled themed widgets # tbgD - background for disabled themed widgets # tcur - insertion cursor color # bclr - hotkey/border color # thlp - help color # tfgI - foreground for external CS # tbgI - background for external CS # tfgM - foreground for menus # tbgM - background for menus # # The themeWindow can be used outside of "color scheme" UI. # E.g., in TKE editor, e_menu and add_shortcuts plugins use it to # be consistent with TKE theme. if {![::apave::cs_Active]} { my themeMandatory $win {*}$args return } lassign $clrs tfg1 tbg1 tfg2 tbg2 tfgS tbgS tfgD tbgD tcur bclr thlp tfgI tbgI tfgM tbgM twfg twbg tHL2 tbHL chkHL res5 res6 res7 if {$tfg1 eq {-}} return if {!$isCS} { # if 'external scheme' is used, register it in _CS_(ALL) # and set it as the current CS # <CS> itemfg mainfg itembg mainbg itemsHL actbg actfg cursor greyed hot emfg embg - menubg winfg winbg itemHL2 #003...reserved... my csAdd [list CS-[expr {[::apave::cs_Max]+1}] $tfg2 $tfg1 $tbg2 $tbg1 $thlp $tbgS $tfgS $tcur $tfgD $bclr $tfgI $tbgI $tfgM $tbgM $twfg $twbg $tHL2 $tbHL $chkHL $res5 $res6 $res7] } if {$tfgI eq {}} {set tfgI $tfg2} if {$tbgI eq {}} {set tbgI $tbg2} if {$tfgM in {{} -}} {set tfgM $tfg1} if {$tbgM eq {}} {set tbgM $tbg1} my Main_Style $tfg1 $tbg1 $tfg2 $tbg2 $tfgS $tbgS $tfgD $tbg1 $tfg1 $tbg2 $tbg1 foreach arg {tfg1 tbg1 tfg2 tbg2 tfgS tbgS tfgD tbgD tcur bclr thlp tfgI tbgI tfgM tbgM twfg twbg tHL2 tbHL chkHL res5 res6 res7 args} { if {$win eq {.}} { set ::apave::_C_($win,$arg) [set $arg] } set ::apave::_CS_(expo,$arg) [set $arg] } set fontdef [font actual apaveFontDef] # configuring themed widgets foreach ts {TLabel TButton TCheckbutton TRadiobutton} { my Ttk_style configure $ts -font $fontdef my Ttk_style configure $ts -foreground $tfg1 my Ttk_style configure $ts -background $tbg1 my Ttk_style map $ts -background [list pressed $tbg2 active $tbg2 alternate $tbg2] my Ttk_style map $ts -foreground [list disabled $tfgD pressed $bclr active $tfg2 alternate $tfg2 focus $tfg2 selected $tfg1] my Ttk_style map $ts -bordercolor [list focus $bclr pressed $bclr] my Ttk_style map $ts -lightcolor [list focus $bclr] my Ttk_style map $ts -darkcolor [list focus $bclr] } my Ttk_style configure TLabelframe.Label -foreground $thlp ;# bclr $tfg2 my Ttk_style configure TLabelframe.Label -background $tbg1 my Ttk_style configure TLabelframe.Label -font $fontdef foreach ts {TNotebook TFrame} { my Ttk_style configure $ts -background $tbg1 my Ttk_style map $ts -background [list focus $tbg1 !focus $tbg1] } foreach ts {TNotebook.Tab} { my Ttk_style configure $ts -font $fontdef if {[my apaveTheme]} { my Ttk_style map $ts -foreground [list {selected !active} $tfgS {!selected !active} $tfgM active $tfg2 {selected active} $tfg2] } my Ttk_style map $ts -background [list {selected !active} $tbgS {!selected !active} $tbgM {!selected active} $tbg2 {selected active} $tbg2] } foreach ts {TEntry Treeview TSpinbox TCombobox TCombobox.Spinbox TMatchbox TNotebook.Tab TScrollbar TScale} { my Ttk_style map $ts -lightcolor [list focus $bclr active $bclr] my Ttk_style map $ts -darkcolor [list focus $bclr active $bclr] } my Ttk_style map TScrollbar -troughcolor [list !active $tbg1 active $tbg2] my Ttk_style map TProgressbar -troughcolor [list !active $tbg2 active $tbg1] my Ttk_style configure TProgressbar -background $tbgS if {[set cs [my csCurrent]]<20} { ttk::style conf TSeparator -background #a2a2a2 } elseif {$cs<23} { ttk::style conf TSeparator -background #656565 } elseif {$cs<28} { ttk::style conf TSeparator -background #3c3c3c } elseif {$cs>35 && $cs<39} { ttk::style conf TSeparator -background #313131 } elseif {$cs==43 || $cs>44} { ttk::style conf TSeparator -background #2e2e2e } foreach ts {TEntry Treeview TSpinbox TCombobox TCombobox.Spinbox TMatchbox} { my Ttk_style configure $ts -font $fontdef my Ttk_style configure $ts -selectforeground $tfgS my Ttk_style configure $ts -selectbackground $tbgS my Ttk_style map $ts -selectforeground [list !focus $::apave::_CS_(!FG)] my Ttk_style map $ts -selectbackground [list !focus $::apave::_CS_(!BG)] my Ttk_style configure $ts -fieldforeground $tfg2 my Ttk_style configure $ts -fieldbackground $tbg2 my Ttk_style configure $ts -insertcolor $tcur my Ttk_style map $ts -bordercolor [list focus $bclr active $bclr] my Ttk_style configure $ts -insertwidth $::apave::_CS_(CURSORWIDTH) if {$ts eq {TCombobox}} { # combobox is sort of individual my Ttk_style configure $ts -foreground $tfg1 my Ttk_style configure $ts -background $tbg1 my Ttk_style map $ts -background [list {readonly focus} $tbg2 {active focus} $tbg2] my Ttk_style map $ts -foreground [list {readonly focus} $tfg2 {active focus} $tfg2] my Ttk_style map $ts -fieldforeground [list {active focus} $tfg2 readonly $tfg2 disabled $tfgD] my Ttk_style map $ts -fieldbackground [list {active focus} $tbg2 {readonly focus} $tbg2 {readonly !focus} $tbg1 disabled $tbgD] } else { my Ttk_style configure $ts -foreground $tfg2 my Ttk_style configure $ts -background $tbg2 my Ttk_style map $ts -foreground [list readonly $tfgD disabled $tfgD selected $tfgS] my Ttk_style map $ts -background [list readonly $tbgD disabled $tbgD selected $tbgS] my Ttk_style map $ts -fieldforeground [list readonly $tfgD disabled $tfgD] my Ttk_style map $ts -fieldbackground [list readonly $tbgD disabled $tbgD] } } ttk::style configure Heading -font $fontdef -relief raised -padding 1 -background $tbg1 option add *Listbox.font $fontdef option add *Menu.font $fontdef my Ttk_style configure TMenubutton -foreground $tfgM my Ttk_style configure TMenubutton -background $tbgM my Ttk_style configure TButton -foreground $tfgM my Ttk_style configure TButton -background $tbgM foreach {nam clr} {back tbg2 fore tfg2 selectBack tbgS selectFore tfgS} { option add *Listbox.${nam}ground [set $clr] } foreach {nam clr} {back tbgM fore tfgM selectBack tbgS selectFore tfgS} { option add *Menu.${nam}ground [set $clr] } foreach ts {TRadiobutton TCheckbutton} { ttk::style map $ts -background [list focus $tbg2 !focus $tbg1] } if {[my csDark]} { # esp. for default/alt/classic themes and dark CS: # checked buttons to be lighter foreach ts {TCheckbutton TRadiobutton} { ttk::style configure $ts -indicatorcolor $tbgM ttk::style map $ts -indicatorcolor [list pressed $tbg2 selected $chkHL] } } # non-themed widgets of button and entry types foreach ts [my NonThemedWidgets button] { set ::apave::_C_($ts,0) 6 set ::apave::_C_($ts,1) "-background $tbg1" set ::apave::_C_($ts,2) "-foreground $tfg1" set ::apave::_C_($ts,3) "-activeforeground $tfg2" set ::apave::_C_($ts,4) "-activebackground $tbg2" set ::apave::_C_($ts,5) "-font {$fontdef}" set ::apave::_C_($ts,6) "-highlightbackground $tfgD" switch -exact -- $ts { checkbutton - radiobutton { set ::apave::_C_($ts,0) 8 set ::apave::_C_($ts,7) "-selectcolor $tbg1" set ::apave::_C_($ts,8) "-highlightbackground $tbg1" } frame - scrollbar - scale - tframe - tnotebook { set ::apave::_C_($ts,0) 8 set ::apave::_C_($ts,4) "-activebackground $bclr" set ::apave::_C_($ts,7) "-troughcolor $tbg1" set ::apave::_C_($ts,8) "-elementborderwidth 2" } menu { set ::apave::_C_($ts,0) 9 set ::apave::_C_($ts,1) "-background $tbgM" set ::apave::_C_($ts,3) "-activeforeground $tfgS" set ::apave::_C_($ts,4) "-activebackground $tbgS" set ::apave::_C_($ts,5) "-disabledforeground $tfgD" set ::apave::_C_($ts,6) "-font {$fontdef}" if {[::iswindows]} { set ::apave::_C_($ts,0) 6 } elseif {[my apaveTheme]} { set ::apave::_C_($ts,7) {-borderwidth 2} set ::apave::_C_($ts,8) {-relief raised} } else { set ::apave::_C_($ts,7) {-borderwidth 1} set ::apave::_C_($ts,8) {-relief groove} } if {[my csDark]} {set c white} {set c black} set ::apave::_C_($ts,9) "-selectcolor $c" } canvas { set ::apave::_C_($ts,1) "-background $tbg2" } } } foreach ts [my NonThemedWidgets entry] { set ::apave::_C_($ts,0) 3 set ::apave::_C_($ts,1) "-foreground $tfg2" set ::apave::_C_($ts,2) "-background $tbg2" set ::apave::_C_($ts,3) "-highlightbackground $tfgD" switch -exact -- $ts { tcombobox - tmatchbox { set ::apave::_C_($ts,0) 8 set ::apave::_C_($ts,4) "-disabledforeground $tfgD" set ::apave::_C_($ts,5) "-disabledbackground $tbgD" set ::apave::_C_($ts,6) "-highlightcolor $bclr" set ::apave::_C_($ts,7) "-font {$fontdef}" set ::apave::_C_($ts,8) "-insertbackground $tcur" } text - entry - tentry { set ::apave::_C_($ts,0) 11 set ::apave::_C_($ts,4) "-selectforeground $tfgS" set ::apave::_C_($ts,5) "-selectbackground $tbgS" set ::apave::_C_($ts,6) "-disabledforeground $tfgD" set ::apave::_C_($ts,7) "-disabledbackground $tbgD" set ::apave::_C_($ts,8) "-highlightcolor $bclr" if {$ts eq {text}} { set ::apave::_C_($ts,9) "-font {[font actual apaveFontMono]}" } else { set ::apave::_C_($ts,9) "-font {$fontdef}" } set ::apave::_C_($ts,10) "-insertwidth $::apave::_CS_(CURSORWIDTH)" set ::apave::_C_($ts,11) "-insertbackground $tcur" } spinbox - tspinbox - listbox - tablelist { set ::apave::_C_($ts,0) 12 set ::apave::_C_($ts,4) "-insertbackground $tcur" set ::apave::_C_($ts,5) "-buttonbackground $tbg2" set ::apave::_C_($ts,6) "-selectforeground $::apave::_CS_(!FG)" set ::apave::_C_($ts,7) "-selectbackground $::apave::_CS_(!BG)" set ::apave::_C_($ts,8) "-disabledforeground $tfgD" set ::apave::_C_($ts,9) "-disabledbackground $tbgD" set ::apave::_C_($ts,10) "-font {$fontdef}" set ::apave::_C_($ts,11) "-insertwidth $::apave::_CS_(CURSORWIDTH)" set ::apave::_C_($ts,12) "-highlightcolor $bclr" } } } foreach ts {disabled} { set ::apave::_C_($ts,0) 4 set ::apave::_C_($ts,1) "-foreground $tfgD" set ::apave::_C_($ts,2) "-background $tbgD" set ::apave::_C_($ts,3) "-disabledforeground $tfgD" set ::apave::_C_($ts,4) "-disabledbackground $tbgD" } foreach ts {readonly} { set ::apave::_C_($ts,0) 2 set ::apave::_C_($ts,1) "-foreground $tfg1" set ::apave::_C_($ts,2) "-background $tbg1" } my themeMandatory $win {*}$args return }



untouchWidgets [::apave::ObjectTheming]ObjectTheming, Top

Makes non-ttk widgets to be untouched by coloring or gets their list.

OBJECT untouchWidgets ?args?
Parameters
argslist of widget globs (e.g. {.em.fr.win.* .em.fr.h1 .em.fr.h2})
Description

If args not set, returns the list of untouched widgets.

See also

themeNonThemed


method untouchWidgets {args} { # Makes non-ttk widgets to be untouched by coloring or gets their list. # args - list of widget globs (e.g. {.em.fr.win.* .em.fr.h1 .em.fr.h2}) # If args not set, returns the list of untouched widgets. # # See also: # themeNonThemed if {[llength $args]==0} {return $::apave::_CS_(untouch)} foreach u $args { if {[lsearch -exact $::apave::_CS_(untouch) $u]==-1} { lappend ::apave::_CS_(untouch) $u } } }

Document generated by Ruff!