diff options
Diffstat (limited to 'lib/leftpanel/sfrwatches.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/leftpanel/sfrwatches.tcl | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/lib/leftpanel/sfrwatches.tcl b/lib/leftpanel/sfrwatches.tcl index ba47dc5..8c1a8e4 100755..100644 --- a/lib/leftpanel/sfrwatches.tcl +++ b/lib/leftpanel/sfrwatches.tcl @@ -2,7 +2,7 @@ # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2009 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +21,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _SFRWATCHES_TCL ] } { +set _SFRWATCHES_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Provides SFR watches for left panel @@ -30,26 +35,26 @@ class SFRWatches { ## COMMON # Font for addresses and register names - common main_font [font create \ - -family $::DEFAULT_FIXED_FONT \ - -size -14 \ - -weight bold \ + common main_font [font create \ + -family $::DEFAULT_FIXED_FONT \ + -size [expr {int(-14 * $::font_size_factor)}] \ + -weight bold \ ] # Just another font but not bold - common roman_font [font create \ - -family $::DEFAULT_FIXED_FONT \ - -size -14 \ + common roman_font [font create \ + -family $::DEFAULT_FIXED_FONT \ + -size [expr {int(-14 * $::font_size_factor)}] \ ] # Fonr for register entry boxes - common entry_font [font create \ - -family $::DEFAULT_FIXED_FONT \ - -size -12 \ - -weight bold \ + common entry_font [font create \ + -family $::DEFAULT_FIXED_FONT \ + -size [expr {int(-12 * $::font_size_factor)}] \ + -weight bold \ ] ## PRIVATE private variable text_widget ;# Widget: Text widget containing SFR watches - private variable scrollbar ;# Widget: Scrollbar for $text_widget + private variable scrollbar {} ;# Widget: Scrollbar for $text_widget private variable search_entry ;# Widget: Search entry box at the bottom of the panel private variable search_clear_but ;# Widget: Button "Clear" at the bottom of the panel private variable main_left_frame ;# Widget: Frame containing $text_widget and its header label @@ -57,20 +62,20 @@ class SFRWatches { private variable validation_ena 1 ;# Bool: SFR entry box validation enabled private variable haddr2idx ;# Array: $haddr2idx($hex_addr) --> row_in_text_widget - 1 private variable addr2idx ;# Array: $addr2idx($dec_addr) --> row_in_text_widget - 1 - private variable reg2idx ;# Array: $addr2idx($register_name_upppercase) --> row_in_text_widget - 1 + private variable reg2idx ;# Array: $addr2idx($register_name_uppercase) --> row_in_text_widget - 1 private variable last_selected_line 0 ;# Int: Selected row in the text widget private variable search_ena 1 ;# Bool: Search enabled private variable menu ;# Widget: Popup menu for the text widget # Variables related to object initialization private variable parent ;# Parent GUI object (tempotary variable) - private variable gui_initialized 0 ;# GUI ready + private variable sfrw_gui_initialized 0 ;# GUI ready constructor {} { } destructor { - if {$gui_initialized} { + if {$sfrw_gui_initialized} { menu_Sbar_remove $menu } } @@ -80,14 +85,14 @@ class SFRWatches { # @return void public method PrepareSFRWatches {_parent} { set parent $_parent - set gui_initialized 0 + set sfrw_gui_initialized 0 } ## Initialize SFR watches GUI # @return void public method CreateSFRWatchesGUI {} { - if {$gui_initialized} {return} - set gui_initialized 1 + if {$sfrw_gui_initialized} {return} + set sfrw_gui_initialized 1 set validation_ena 0 create_GUI @@ -106,10 +111,10 @@ class SFRWatches { # @parm String reg - SFR name (e.g. PSW) # @return Widget - Created entry box private method create_entry {i type addr reg} { - # Determinate entry box width + # Determine entry box width if {$type == {hex}} { set width 2 - } { + } else { set width 3 } @@ -146,7 +151,7 @@ class SFRWatches { $text_widget.dec_entry_${i} selection clear update $text_widget.dec_entry_${i} icursor 0" - } { + } else { bind $entry <Key-Left> " focus $text_widget.hex_entry_${i} $text_widget.hex_entry_${i} selection clear @@ -165,7 +170,7 @@ class SFRWatches { # Iterate over defined SFRs ({{addr name} ... }) foreach reg [$this simulator_get_sfrs] { - # Determinate hexadecimal address + # Determine hexadecimal address set addr [lindex $reg 0] set hex_addr [format %X $addr] if {[string length $hex_addr] == 1} { @@ -173,7 +178,7 @@ class SFRWatches { } elseif {[string length $hex_addr] == 3} { set hex_addr [string replace $hex_addr 0 0] } - # Determinate register name and make it 8 characters long + # Determine register name and make it 8 characters long set reg [lindex $reg 1] set reg_org $reg switch -- $reg { @@ -264,7 +269,7 @@ class SFRWatches { {} "Set this register to 0"} {command {Set to 0xFF} {} 9 "sfr_watches_set_current_to FF" {} "Set this register to 255"} - } $menu 0 "$this " 0 {} + } $menu 0 "$this " 0 {} [namespace current] # Set event bindings for the text widget bindtags $text_widget $text_widget @@ -321,13 +326,17 @@ class SFRWatches { # @parm Float frac1 - 2nd fraction # @return void public method sfr_watches_scroll_set {frac0 frac1} { + if {$scrollbar == {}} { + return + } + # Hide scrollbar if {$frac0 == 0 && $frac1 == 1} { if {[winfo ismapped $scrollbar]} { pack forget $scrollbar } # Show scrollbar - } { + } else { if {![winfo ismapped $scrollbar]} { pack $scrollbar \ -side left \ @@ -351,7 +360,7 @@ class SFRWatches { $search_entry configure -style TEntry sfr_watches_select_line 1 0 hex return 1 - } { + } else { $search_clear_but configure -state normal } @@ -363,7 +372,7 @@ class SFRWatches { # Search successful if {![string first $string $str]} { $search_entry configure -style StringFound.TEntry - sfr_watches_select_line 1 [expr {[subst "\${${arr}(${str})}"] + 1}] hex + sfr_watches_select_line 1 [expr {[subst -nocommands "\${${arr}(${str})}"] + 1}] hex return 1 } } @@ -392,7 +401,7 @@ class SFRWatches { -bg {#FFFFFF} -disabledbackground {#FFFFFF} } set cursor [$text_widget.${type}_entry_$last_selected_line index insert] - } { + } else { set cursor 0 } @@ -454,7 +463,7 @@ class SFRWatches { return 0 } set value [expr "0x$value"] - } { + } else { if {![string is digit $value]} { set validation_ena 1 return 0 @@ -475,7 +484,7 @@ class SFRWatches { if {$type == {hex}} { $text_widget.dec_entry_$addr2idx($addr) delete 0 end $text_widget.dec_entry_$addr2idx($addr) insert 0 $value - } { + } else { set value [format %X $value] if {[string length $value] == 1} { set value "0$value" @@ -492,7 +501,7 @@ class SFRWatches { ## Remove all SFRs for the text widget and unregister them # @return void private method clear_gui {} { - if {!$gui_initialized} {return} + if {!$sfrw_gui_initialized} {return} # Clear SFR name label highlight in simultor contol panel if {$last_selected_line} { @@ -518,13 +527,13 @@ class SFRWatches { # @parm Int new_val - New SFR value # @return void public method sfr_watches_sync {addr new_val} { - if {!$gui_initialized} {return} + if {!$sfrw_gui_initialized} {return} # Prevent recursion if {!$validation_ena} {return} set validation_ena 0 - # Check if this SFR is avaliable here + # Check if this SFR is available here if {[lsearch [array names addr2idx] $addr] == -1} { set validation_ena 1 return @@ -560,7 +569,7 @@ class SFRWatches { ## Enable this panel # @return vois public method sfr_watches_enable {} { - if {!$gui_initialized} {return} + if {!$sfrw_gui_initialized} {return} $menu entryconfigure [::mc "Set to 0x00"] -state normal $menu entryconfigure [::mc "Set to 0xFF"] -state normal for {set i 0} {$i < $entry_count} {incr i} { @@ -572,7 +581,7 @@ class SFRWatches { ## Disable this panel # @return vois public method sfr_watches_disable {} { - if {!$gui_initialized} {return} + if {!$sfrw_gui_initialized} {return} $menu entryconfigure [::mc "Set to 0x00"] -state disabled $menu entryconfigure [::mc "Set to 0xFF"] -state disabled for {set i 0} {$i < $entry_count} {incr i} { @@ -582,10 +591,10 @@ class SFRWatches { } ## This function shuld be call after processor was changed - # Reload avaliable SFRs + # Reload available SFRs # @return void public method sfr_watches_commit_new_sfr_set {} { - if {!$gui_initialized} {return} + if {!$sfrw_gui_initialized} {return} clear_gui fill_gui } @@ -618,3 +627,7 @@ class SFRWatches { sfr_watches_select_line 0 $line $type } } + +# >>> File inclusion guard +} +# <<< File inclusion guard |