summaryrefslogtreecommitdiffstats
path: root/library/iconbadges.tcl
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-08-16 18:58:21 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-08-16 18:58:21 (GMT)
commit4ee27eb807bf07999817c7311d4bd71c4173f273 (patch)
tree59d06257085b094eed89e8cccea522de6ecf01b4 /library/iconbadges.tcl
parent797ddeb8ac2455c7fd761a4ad3516b9d438c18e2 (diff)
downloadtk-4ee27eb807bf07999817c7311d4bd71c4173f273.zip
tk-4ee27eb807bf07999817c7311d4bd71c4173f273.tar.gz
tk-4ee27eb807bf07999817c7311d4bd71c4173f273.tar.bz2
Documentation update
Diffstat (limited to 'library/iconbadges.tcl')
-rw-r--r--library/iconbadges.tcl58
1 files changed, 28 insertions, 30 deletions
diff --git a/library/iconbadges.tcl b/library/iconbadges.tcl
index f7be680..44017e5 100644
--- a/library/iconbadges.tcl
+++ b/library/iconbadges.tcl
@@ -195,43 +195,41 @@ image create photo ::tk::icons::!-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAAS
# badgenumber - number to draw over the icon
if {[tk windowingsystem] eq "x11"} {
-proc ::tk::icons::IconBadge {win badgenumber} {
+ proc ::tk::icons::IconBadge {win badgenumber} {
- variable ::tk::icons::base_icon
+ variable ::tk::icons::base_icon
- set badge ""
-
- image create photo overlay
-
- if {$::tk::icons::base_icon eq ""} {
- return -code error "You must set the value of ::tk::icons::base_icon\
- to a Tk photo before setting an icon badge"
- }
+ set badge ""
+
+ image create photo overlay
+
+ if {$::tk::icons::base_icon eq ""} {
+ return -code error "You must set the value of \"::tk::icons::base_icon\" to a Tk photo before setting an icon badge"
+ }
- if {[wm iconphoto $win] eq ""} {
- return -code error "You must set a Tk image as a window icon via the wm\ iconphoto command before setting an icon badge"
-}
+ if {[wm iconphoto $win] eq ""} {
+ return -code error "You must set a Tk image as a window icon via the \"wm iconphoto\" command before setting an icon badge"
+ }
+ if {$badgenumber eq ""} {
+ wm iconphoto $win $::tk::icons::base_icon
+ return
+ }
- if {$badgenumber eq ""} {
- wm iconphoto $win $::tk::icons::base_icon
- return
- }
+ update idletasks
- update idletasks
+ wm iconphoto $win $::tk::icons::base_icon
- wm iconphoto $win $::tk::icons::base_icon
+ if {[expr $badgenumber > 9] == 1} {
+ set badge ::tk::icons::9plus-badge
+ } else {
+ set badge ::tk::icons::$badgenumber-badge
+ }
- if {[expr $badgenumber > 9] == 1} {
- set badge ::tk::icons::9plus-badge
- } else {
- set badge ::tk::icons::$badgenumber-badge
- }
+ update idletasks
+ overlay copy $::tk::icons::base_icon
+ overlay copy $badge -from 0 0 18 18 -to 18 0
+ wm iconphoto $win overlay
- update idletasks
- overlay copy $::tk::icons::base_icon
- overlay copy $badge -from 0 0 18 18 -to 18 0
- wm iconphoto $win overlay
-
-}
+ }
}