summaryrefslogtreecommitdiff
path: root/lib/pale/ledpanel.tcl
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-05-08 15:59:31 +0200
commit47aa8b00b2b11df13a100489e0f904a4947177ef (patch)
treeb35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/pale/ledpanel.tcl
parent5b8466f7fae0e071c0f4eda13051c93313910028 (diff)
Import Upstream version 1.4.7
Diffstat (limited to 'lib/pale/ledpanel.tcl')
-rw-r--r--[-rwxr-xr-x]lib/pale/ledpanel.tcl97
1 files changed, 71 insertions, 26 deletions
diff --git a/lib/pale/ledpanel.tcl b/lib/pale/ledpanel.tcl
index a05bb79..a39799f 100755..100644
--- a/lib/pale/ledpanel.tcl
+++ b/lib/pale/ledpanel.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 _LEDPANEL_TCL ] } {
+set _LEDPANEL_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
@@ -36,8 +41,12 @@ class LedPanel {
inherit VirtualHWComponent
# Font: Font to be used in the panel -- bold
- common cb_font [font create -weight bold -size -10 -family {helvetica}]
- common COMPONENT_NAME "LED panel" ;# Name of this component
+ common cb_font [font create \
+ -weight bold \
+ -size [expr {int(-10 * $::font_size_factor)}] \
+ -family {helvetica} \
+ ]
+ common COMPONENT_NAME "LED Panel" ;# Name of this component
common CLASS_NAME "LedPanel" ;# Name of this class
common COMPONENT_ICON {ledpanel} ;# Icon for this panel (16x16)
@@ -71,9 +80,14 @@ class LedPanel {
"Save configuration into a file"}
{command {Load configuration} {} 0 "load_from" {fileopen}
"Load configuration from a file"}
+ {separator}
+ {checkbutton "Window always on top" {} {::LedPanel::menu_keep_win_on_top}
+ 1 0 0 {keep_win_on_top_changed}
+ ""}
}
+ private variable keep_win_on_top 0 ;# Bool: Toplevel window
private variable conf_led_color {red} ;# Color: Selected color for LED's
private variable leds ;# Array of CanvasObject (image): LED's
private variable connection_port ;# Array of Int: Index is key number, value is port number or {-}
@@ -122,6 +136,17 @@ class LedPanel {
destroy $win
}
+ ## Value of configuration menu variable "keep_win_on_top" has been changed
+ # @return void
+ public method keep_win_on_top_changed {} {
+ set keep_win_on_top $LedPanel::menu_keep_win_on_top
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ } else {
+ wm attributes $win -topmost 0 -alpha 1.0
+ }
+ }
+
## Reconnect the specified LED to another port pin
# @parm Int i - LED number (0..7)
# @return void
@@ -135,7 +160,8 @@ class LedPanel {
# Change state of the device
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
# Set flag modified
@@ -148,7 +174,8 @@ class LedPanel {
set conf_led_color ${::LedPanel::color}
if {$drawing_on} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
set_modified
}
@@ -157,7 +184,7 @@ class LedPanel {
# @return void
private method create_gui {} {
# Create panel window and canvas widget
- set win [toplevel .ledpanel$count -class $component_name -bg {#EEEEEE}]
+ set win [toplevel .ledpanel$count -class $component_name -bg ${::COMMON_BG_COLOR}]
set canvas_widget [canvas $win.canvas \
-bg white -width 0 -height 0 \
-highlightthickness 0 \
@@ -167,7 +194,7 @@ class LedPanel {
set led_y 35
set cb_p_y 65
set cb_b_y 85
- set usr_n_y 105
+ set usr_n_y 110
set x 50
$canvas_widget create text 5 $cb_p_y \
-text [mc "PORT"] \
@@ -177,16 +204,16 @@ class LedPanel {
-text [mc "BIT"] \
-font $cb_font \
-anchor w
- $canvas_widget create text 5 $usr_n_y \
+ $canvas_widget create text 30 $usr_n_y \
-text [mc "Note"] \
-font $cb_font \
- -anchor w
- $canvas_widget create window 208 $usr_n_y \
+ -anchor e
+ $canvas_widget create window 35 $usr_n_y \
-window [ttk::entry $canvas_widget.usr_note \
- -validate all \
+ -validate key \
-validatecommand "$this set_modified" \
] \
- -width 330
+ -width 330 -anchor w
bindtags $canvas_widget.usr_note \
[list $canvas_widget.usr_note TEntry $win all .]
@@ -253,9 +280,9 @@ class LedPanel {
pack $canvas_widget -fill both -expand 1
# Set window parameters
- wm geometry $win =380x120
+ wm minsize $win 380 130
wm iconphoto $win ::ICONS::16::$component_icon
- wm title $win "[mc $component_name] - [string trim $project {:}] - MCU 8051 IDE"
+ wm title $win "[mc $component_name] - [$project cget -projectName] - MCU 8051 IDE"
wm resizable $win 0 0
wm protocol $win WM_DELETE_WINDOW "$this close_window"
bindtags $win [list $win Toplevel all .]
@@ -332,12 +359,12 @@ class LedPanel {
# @return void
public method mcu_changed {} {
# Refresh lists of possible values in port selection ComboBoxes
- set avaliable_ports [concat - [$project pale_get_avaliable_ports]]
+ set available_ports [concat - [$project pale_get_available_ports]]
for {set i 0} {$i < 8} {incr i} {
- $canvas_widget.cb_p$i configure -values $avaliable_ports
+ $canvas_widget.cb_p$i configure -values $available_ports
- if {[lsearch -ascii -exact $avaliable_ports $connection_port($i)] == -1} {
+ if {[lsearch -ascii -exact $available_ports $connection_port($i)] == -1} {
$canvas_widget.cb_p$i current 0
set connection_port($i) {-}
}
@@ -352,11 +379,13 @@ class LedPanel {
# '|' - High frequency
# 'X' - Access to external memory
# '?' - No volatge
- # '-' - Undeterminable value (some noise)
+ # '-' - Indeterminable value (some noise)
# '=' - High forced to low
# '0' - Logical 0
# '1' - Logical 1
- public method new_state {state} {
+ public method new_state {_state} {
+ upvar $_state state
+
for {set i 0} {$i < 8} {incr i} {
# Determinate index in the list of port states
set pp [which_port_pin $i]
@@ -409,6 +438,7 @@ class LedPanel {
[wm geometry $win] \
[$canvas_widget.usr_note get] \
$conf_led_color \
+ $keep_win_on_top \
] \
]
}
@@ -424,7 +454,7 @@ class LedPanel {
# Restore window geometry
if {[string length [lindex $state 2]]} {
- wm geometry $win [lindex $state 2]
+ wm geometry $win [regsub {^\=?\d+x\d+} [lindex $state 2] [join [wm minsize $win] {x}]]
}
# Load user note
@@ -434,6 +464,13 @@ class LedPanel {
# Restore LED's configuration
set conf_led_color [lindex $state 4]
+ if {[lindex $state 5] != {}} {
+ set keep_win_on_top [lindex $state 5]
+ if {$keep_win_on_top} {
+ wm attributes $win -topmost 1 -alpha 0.8
+ }
+ }
+
# Restore state of ComboBoxes
for {set i 0} {$i < 8} {incr i} {
## PIN
@@ -462,12 +499,13 @@ class LedPanel {
}
# Accept new state of ports
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
update
# Fail
}]} then {
- puts "Unable to load config for $class_name"
+ puts "Unable to load configuration for $class_name"
return 0
# Success
@@ -480,7 +518,8 @@ class LedPanel {
## Simulated MCU has been reseted
# @return void
public method reset {} {
- new_state [$project pale_get_true_state]
+ set state [$project pale_get_true_state]
+ new_state state
}
@@ -492,6 +531,7 @@ class LedPanel {
# @return void
public method config_menu_special {} {
set ::${class_name}::color $conf_led_color
+ set ::${class_name}::menu_keep_win_on_top $keep_win_on_top
}
## This method is called after configuration menu has beed created
@@ -510,7 +550,7 @@ class LedPanel {
#
# Note: There is defined text tag "tag_bold" in the text widget
public method show_help_special {text_widget} {
- $text_widget insert insert [mc "This tool consists of 8 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file (with extension vhc). And can be loaded from that file later. LED colors are configurable.\n\n"]
+ $text_widget insert insert [mc "This tool consists of 8 LED's. Each of them can be connected to any port pin of the simulated uC. Connections with the uC are made with ComboBoxes on the bottom of the panel. Panel configuration can be saved to a file with extension vhc, and can be loaded from that file later. LED colors are configurable.\n\n"]
$text_widget insert insert [mc "LED states:"]
$text_widget tag add tag_bold {insert linestart} {insert lineend}
@@ -536,8 +576,13 @@ class LedPanel {
$canvas_widget itemconfigure $leds($i) \
-image ::ICONS::16::ledgray
}
- } {
- new_state [$project pale_get_true_state]
+ } else {
+ set state [$project pale_get_true_state]
+ new_state state
}
}
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard