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

📄 timefield.itk

📁 windows下的GDB insight前端
💻 ITK
📖 第 1 页 / 共 3 页
字号:
      } else {        set newclicks [::clock scan "$prevtime 1 $_cfield ago"]        show [::clock format $newclicks -format $_formatString]      }    }    Tab {      #      # A tab key moves the "hour:minute:second" field forward by one unless      # the current field is the second.  In that case we'll let tab      # do what is supposed to and pass the focus onto the next widget.      #      if {$state == 0} {        if {($itk_option(-format) == "civilian" && $_cfield == $lastField)} {          _setField hour          return -code continue        }        _moveField forward      #      # A ctrl-tab key moves the hour:minute:second field backwards by one       # unless the current field is the hour.  In that case we'll let       # tab take the focus to a previous widget.      #      } elseif {$state == 4} {        if {$_cfield == "hour"} {          _setField hour          return -code continue        }        _moveField backward      }    }    Right {      #      # A right arrow key moves the insert cursor to the right one.      #      $_forward    }    Left - BackSpace - Delete {      #      # A left arrow, backspace, or delete key moves the insert cursor       # to the left one.  This is what you expect for the left arrow      # and since the whole widget always operates in overstrike mode,      # it makes the most sense for backspace and delete to do the same.      #      $_backward    }    Return {      #      # A Return key invokes the optionally specified command option.      #      uplevel #0 $itk_option(-command)    }          default {    }  }  return -code break}# ------------------------------------------------------------------# PROTECTED METHOD: _toggleAmPm## Internal method which toggles the displayed time# between "AM" and "PM" when format is "civilian".# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_toggleAmPm {} {  set firstChar  [string index $_timeVar 9]  $itk_component(time) delete 9 10  $itk_component(time) insert 9 [expr {($firstChar == "A") ? "P" : "A"}]  $itk_component(time) icursor 9  set _timeVar [$itk_component(time) get]}# ------------------------------------------------------------------# PROTECTED METHOD: _setField field## Adjusts the current field to be that of the argument, setting the# insert cursor appropriately.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_setField {field} {  # Move the position of the cursor to the first character of the  # field given by the argument:  #  # Field   First Character Index  # -----   ---------------------  # hour    0  # minute  3  # second  6  # ampm    9  #  switch $field {    hour {      $itk_component(time) icursor 0    }    minute {      $itk_component(time) icursor 3    }    second {      $itk_component(time) icursor 6    }    ampm {      if {$itk_option(-format) == "military"} {        error "bad field: \"$field\", must be hour, minute or second"      }      $itk_component(time) icursor 9    }    default {      if {$itk_option(-format) == "military"} {        error "bad field: \"$field\", must be hour, minute or second"      } else {        error "bad field: \"$field\", must be hour, minute, second or ampm"      }    }  }  set _cfield $field  return $_cfield}# ------------------------------------------------------------------# PROTECTED METHOD: _moveField## Moves the cursor one field forward or backward.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_moveField {direction} {  # Since the value "_fields" list variable is always either value:  #   military => {hour minute second}  #   civilian => {hour minute second ampm}  #  # the index of the previous or next field index can be determined  # by subtracting or adding 1 to current the index, respectively.  #   set index [lsearch $_fields $_cfield]  expr {($direction == "forward") ? [incr index] : [incr index -1]}  if {$index == $_numFields} {    set index 0  } elseif {$index < 0} {    set index [expr {$_numFields-1}]  }  _setField [lindex $_fields $index]}# ------------------------------------------------------------------# PROTECTED METHOD: _whichField## Returns the current field that the cursor is positioned within.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_whichField {} {  # Return the current field based on the position of the cursor.  #  # Field   Index  # -----   -----  # hour    0,1  # minute  3,4  # second  6,7  # ampm    9,10  #  set icursor [$itk_component(time) index insert]  switch $icursor {    0 - 1 {      set _cfield hour    }    3 - 4 {      set _cfield minute    }    6 - 7 {      set _cfield second    }    9 - 10 {      set _cfield ampm    }  }  return $_cfield}# ------------------------------------------------------------------# PROTECTED METHOD: _forwardCivilian## Internal method which moves the cursor forward by one character# jumping over the slashes and wrapping.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_forwardCivilian {} {  #  # If the insertion cursor is at the second digit  # of either the hour, minute or second field, then  # move the cursor to the first digit of the right-most field.  #  # else move the insertion cursor right one character  #  set icursor [$itk_component(time) index insert]  switch $icursor {    1 {      _setField minute    }    4 {      _setField second    }    7 {      _setField ampm    }    9 - 10 {      _setField hour    }    default {      $itk_component(time) icursor [expr {$icursor+1}]    }  }}# ------------------------------------------------------------------# PROTECTED METHOD: _forwardMilitary## Internal method which moves the cursor forward by one character# jumping over the slashes and wrapping.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_forwardMilitary {} {  #  # If the insertion cursor is at the second digit of either  # the hour, minute or second field, then move the cursor to  # the first digit of the right-most field.  #  # else move the insertion cursor right one character  #  set icursor [$itk_component(time) index insert]  switch $icursor {    1 {      _setField minute    }    4 {      _setField second    }    7 {      _setField hour    }    default {      $itk_component(time) icursor [expr {$icursor+1}]    }  }}# ------------------------------------------------------------------# PROTECTED METHOD: _backwardCivilian## Internal method which moves the cursor backward by one character# jumping over the ":" and wrapping.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_backwardCivilian {} {  #  # If the insertion cursor is at the first character  # of either the minute or second field or at the ampm  # field, then move the cursor to the second character  # of the left-most field.  #  # else if the insertion cursor is at the first digit of the  # hour field, then move the cursor to the first character  # of the ampm field.  #  # else move the insertion cursor left one character  #  set icursor [$itk_component(time) index insert]  switch $icursor {    9 {      _setField second      $itk_component(time) icursor 7    }    6 {      _setField minute      $itk_component(time) icursor 4    }    3 {      _setField hour      $itk_component(time) icursor 1    }    0 {      _setField ampm      $itk_component(time) icursor 9    }    default {      $itk_component(time) icursor [expr {$icursor-1}]    }  }}# ------------------------------------------------------------------# PROTECTED METHOD: _backwardMilitary## Internal method which moves the cursor backward by one character# jumping over the slashes and wrapping.# ------------------------------------------------------------------itcl::body iwidgets::Timefield::_backwardMilitary {} {  #  # If the insertion cursor is at the first digit of either  # the minute or second field, then move the cursor to the  # second character of the left-most field.  #  # else if the insertion cursor is at the first digit of the  # hour field, then move the cursor to the second digit  # of the second field.  #  # else move the insertion cursor left one character  #  set icursor [$itk_component(time) index insert]  switch $icursor {    6 {      _setField minute      $itk_component(time) icursor 4    }    3 {      _setField hour      $itk_component(time) icursor 1    }    0 {      _setField second      $itk_component(time) icursor 7    }    default {      $itk_component(time) icursor [expr {$icursor-1}]    }  }}

⌨️ 快捷键说明

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