⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendar.itk

📁 这是一个Linux下的集成开发环境
💻 ITK
📖 第 1 页 / 共 3 页
字号:
# ------------------------------------------------------------------# OPTION: -weekdaybackground## Specifies the background for the weekdays which allows it to# be visually distinguished from the weekend.# ------------------------------------------------------------------configbody iwidgets::Calendar::weekdaybackground {    if {$_initialized} {	$itk_component(page) itemconfigure weekday \		-fill $itk_option(-weekdaybackground)    }}# ------------------------------------------------------------------# OPTION: -weekendbackground## Specifies the background for the weekdays which allows it to# be visually distinguished from the weekdays.# ------------------------------------------------------------------configbody iwidgets::Calendar::weekendbackground {    if {$_initialized} {	$itk_component(page) itemconfigure weekend \		-fill $itk_option(-weekendbackground)    }}# ------------------------------------------------------------------# OPTION: -foreground## Specifies the foreground color for the textual items, buttons,# and divider on the calendar.# ------------------------------------------------------------------configbody iwidgets::Calendar::foreground {    if {$_initialized} {	$itk_component(page) itemconfigure text \		-fill $itk_option(-foreground)	$itk_component(page) itemconfigure line \		-fill $itk_option(-foreground)    }}# ------------------------------------------------------------------# OPTION: -outline## Specifies the outline color used to surround the date text.# ------------------------------------------------------------------configbody iwidgets::Calendar::outline {    if {$_initialized} {	$itk_component(page) itemconfigure square \		-outline $itk_option(-outline)    }}# ------------------------------------------------------------------# OPTION: -buttonforeground## Specifies the foreground color of the forward and backward buttons.# ------------------------------------------------------------------configbody iwidgets::Calendar::buttonforeground {    if {$_initialized} {	if {$itk_option(-forwardimage) == {}} {	    if {[lsearch [image names] $this-forward] != -1} {		$this-forward configure \		    -foreground $itk_option(-buttonforeground)	    }	} else {	    $itk_component(forward) configure \		    -foreground $itk_option(-buttonforeground)	}		if {$itk_option(-backwardimage) == {}} {	    if {[lsearch [image names] $this-backward] != -1} {		$this-backward configure \		    -foreground $itk_option(-buttonforeground)	    }	} else {	    $itk_component(-backward) configure \		    -foreground $itk_option(-buttonforeground)	}    }}# ------------------------------------------------------------------# OPTION: -selectcolor## Specifies the color of the ring displayed that distinguishes the # currently selected date.  # ------------------------------------------------------------------configbody iwidgets::Calendar::selectcolor {    if {$_initialized} {	$itk_component(page) itemconfigure $_selected-sensor \		-outline $itk_option(-selectcolor)     }}# ------------------------------------------------------------------# OPTION: -selectthickness## Specifies the thickness of the ring displayed that distinguishes # the currently selected date.  # ------------------------------------------------------------------configbody iwidgets::Calendar::selectthickness {    if {$_initialized} {	$itk_component(page) itemconfigure $_selected-sensor \		-width $itk_option(-selectthickness)     }}# ------------------------------------------------------------------# OPTION: -titlefont## Specifies the font used for the title text that consists of the # month and year.# ------------------------------------------------------------------configbody iwidgets::Calendar::titlefont {    if {$_initialized} {	$itk_component(page) itemconfigure title \		-font $itk_option(-titlefont)    }}# ------------------------------------------------------------------# OPTION: -datefont## Specifies the font used for the date text that consists of the # day of the month.# ------------------------------------------------------------------configbody iwidgets::Calendar::datefont {    if {$_initialized} {	$itk_component(page) itemconfigure date \		-font $itk_option(-datefont)    }}# ------------------------------------------------------------------# OPTION: -currentdatefont## Specifies the font used for the current date text.# ------------------------------------------------------------------configbody iwidgets::Calendar::currentdatefont {    if {$_initialized} {	$itk_component(page) itemconfigure now \		-font $itk_option(-currentdatefont)    }}# ------------------------------------------------------------------# OPTION: -dayfont## Specifies the font used for the day of the week text.# ------------------------------------------------------------------configbody iwidgets::Calendar::dayfont {    if {$_initialized} {	$itk_component(page) itemconfigure days \		-font $itk_option(-dayfont)    }}# ------------------------------------------------------------------# OPTION: -startday## Specifies the starting day for the week.  The value must be a day of the# week: sunday, monday, tuesday, wednesday, thursday, friday, or# saturday.  The default is sunday.# ------------------------------------------------------------------configbody iwidgets::Calendar::startday {    set day [string tolower $itk_option(-startday)]    switch $day {	sunday {set _offset 0}	monday {set _offset 1}	tuesday {set _offset 2}	wednesday {set _offset 3}	thursday {set _offset 4}	friday {set _offset 5}	saturday {set _offset 6}	default {	    error "bad startday option \"$itk_option(-startday)\":\                   should be sunday, monday, tuesday, wednesday,\                   thursday, friday, or saturday"	}    }    if {$_initialized} {	$itk_component(page) delete all-page	_redraw    }}# ------------------------------------------------------------------#                            METHODS# ------------------------------------------------------------------# ------------------------------------------------------------------# PUBLIC METHOD: get ?format?## Returns the currently selected date in one of two formats, string # or as an integer clock value using the -string and -clicks# options respectively.  The default is by string.  Reference the # clock command for more information on obtaining dates and their # formats.# ------------------------------------------------------------------body iwidgets::Calendar::get {{format "-string"}} {    switch -- $format {	"-string" {	    return $_selected	}	"-clicks" {	    return [clock scan $_selected]	}	default {	    error "bad format option \"$format\":\                   should be -string or -clicks"	}    }}# ------------------------------------------------------------------# PUBLIC METHOD: select date_## Changes the currently selected date to the value specified.# ------------------------------------------------------------------body iwidgets::Calendar::select {{date_ "now"}} {    if {$date_ == "now"} {	set time [clock seconds]    } else {	if {[catch {clock format $date_}] == 0} {	    set time $date_	} elseif {[catch {set time [clock scan $date_]}] != 0} {	    error "bad date: \"$date_\", must be a valid date string, clock clicks value or the keyword now"	}    }    _select [clock format $time -format "%m/%d/%Y"]}# ------------------------------------------------------------------# PUBLIC METHOD: show date_## Changes the currently display month to be that of the specified # date.# ------------------------------------------------------------------body iwidgets::Calendar::show {{date_ "now"}} {    if {$date_ == "now"} {	set _time [clock seconds]    } else {	if {[catch {clock format $date_}] == 0} {	    set _time $date_	} elseif {[catch {set _time [clock scan $date_]}] != 0} {	    error "bad date: \"$date_\", must be a valid date string, clock clicks value or the keyword now"	}    }    $itk_component(page) delete all-page    _redraw}# ------------------------------------------------------------------# PROTECTED METHOD: _drawtext canvas_ day_ date_ now_#                             x0_ y0_ x1_ y1_## Draws the text in the date square.  The method is protected such that# it can be overridden in derived classes that may wish to add their# own unique text.  The method receives the day to draw along with# the coordinates of the square.# ------------------------------------------------------------------body iwidgets::Calendar::_drawtext {canvas_ day_ date_ now_ x0_ y0_ x1_ y1_} {    set item [$canvas_ create text \		  [expr (($x1_ - $x0_) / 2) + $x0_] \		  [expr (($y1_ -$y0_) / 2) + $y0_ + 1] \		  -anchor center -text "$day_" \		  -fill $itk_option(-foreground)]    if {$date_ == $now_} {	$canvas_ itemconfigure $item \	    -font $itk_option(-currentdatefont) \	    -tags [list all-page date text now]    } else {	$canvas_ itemconfigure $item \	    -font $itk_option(-datefont) \	    -tags [list all-page date text]    }}# ------------------------------------------------------------------# PRIVATE METHOD: _configureHandler## Processes a configure event received on the canvas.  The method# deletes all the current canvas items and forces a redraw.# ------------------------------------------------------------------body iwidgets::Calendar::_configureHandler {} {    set _initialized 1    $itk_component(page) delete all    _redraw}# ------------------------------------------------------------------# PRIVATE METHOD: _change delta_## Changes the current month displayed in the calendar, moving# forward or backward by <delta_> months where <delta_> is +/-# some number.# ------------------------------------------------------------------body iwidgets::Calendar::_change {delta_} {    set dir [expr ($delta_ > 0) ? 1 : -1]    set month [clock format $_time -format "%m"]    set month [string trimleft $month 0]    set year [clock format $_time -format "%Y"]    for {set i 0} {$i < abs($delta_)} {incr i} {        incr month $dir

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -