1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 | ###############################################################################
# Copyright (c) 2007-2024 by Altair Engineering, Inc.
# All rights reserved.
#
# Altair Engineering, Inc. makes this software available as part of the Vision
# tool platform. As long as you are a licensee of the Vision tool platform
# you may make copies of the software and modify it to be used within the
# Vision tool platform, but you must include all of this notice on any copy.
# Redistribution without written permission to any third party, with or
# without modification, is not permitted.
# Altair Engineering, Inc. does not warrant that this software is error free
# or fit for any purpose. Altair Engineering, Inc. disclaims any liability for
# all claims, expenses, losses, damages and costs any user may incur as a
# result of using, copying or modifying the software.
# =============================================================================
# @userware
# Quick Highlight Color Change
# @section
# GUI Specific Userware Examples
# @description
# Show all highlight colors below the Console window. From there the
# user can select his favorite color. The visibility of the widget can be
# toggled from the Userware menu.
# @files
# quickHiCol.tcl
# @tag
# gui
###############################################################################
# =============================================================================
# CreateQuickCol - Create a small toplevel widget which allows you to select a
# highlight color.
# =============================================================================
#
proc CreateQuickCol {c} {
global Settings Global
canvas $c -takefocus 0 -highlightthickness 0
set space 5
set x 5
set y 5
set w 20
set h 20
for {set i 0} {$i < $Global(hiColorMax)} {incr i} {
set fg [gui settings get "color:objectHighlight$i"]
$c create rectangle $x $y [incr x $w] [expr {$y + $h}] -fill $fg \
-outline black -width 1 -tags col$i
incr x $space
$c bind col$i <ButtonRelease-1> [list selectHiCol $c $i true]
}
set bbox [$c bbox all]
$c configure -width [lindex $bbox 2]
$c configure -height [lindex $bbox 3]
selectHiCol $c [gui settings get "hiColor"] false
set key "hiColor"
trace add variable Settings($key) write [list traceHiCol $c]
}
# -----------------------------------------------------------------------------
# traceHiCol -
# -----------------------------------------------------------------------------
#
proc traceHiCol {w name1 name2 ops} {
global Global
for {set i 0} {$i < $Global(hiColorMax)} {incr i} {
if {$i == [gui settings get "hiColor"]} {
$w itemconfigure col$i -width 2
} else {
$w itemconfigure col$i -width 1
}
}
}
# -----------------------------------------------------------------------------
# selectHiCol - Change the global settings for highlight and show visual
# feedback.
# -----------------------------------------------------------------------------
#
proc selectHiCol {w col interactive} {
global Global
gui settings set "hiColor" $col
for {set i 0} {$i < $Global(hiColorMax)} {incr i} {
if {$i == $col} {
$w itemconfigure col$i -width 2
} else {
$w itemconfigure col$i -width 1
}
}
if {$interactive} {
focus [gui schem nlv]
}
}
# -----------------------------------------------------------------------------
# toggleQuickHil -
# -----------------------------------------------------------------------------
#
proc toggleQuickHil {c} {
global quickhil
if {$quickhil} {
grid $c -row 7 -column 0
} else {
grid forget $c
}
}
##
#
#
set quickhil 1
CreateQuickCol .quickHiCol
gui menu checkbutton {"Userware" "_Show Quick Highlight"} \
{toggleQuickHil .quickHiCol} \
quickhil
toggleQuickHil .quickHiCol
|