Eskil

Check-in [62ba2f60a5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Handle multiple screens better for balloon help
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 62ba2f60a51ebbf439b0ff23cd011a718d05ee1d6302db3d1de62ed802a8114a
User & Date: peter 2020-01-07 10:06:56
Context
2020-01-15
14:15
Support -norun for dir diff. Prune empty directories in dir diff. Added -includefile/dir command line, for dir diff. check-in: e8c33e9a2c user: peter tags: trunk
2020-01-07
10:06
Handle multiple screens better for balloon help check-in: 62ba2f60a5 user: peter tags: trunk
2019-11-10
19:47
More Edit Mode commands check-in: 30dff04537 user: peter tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to eskil.vfs/lib/psballoon/psballoon.tcl.

119
120
121
122
123
124
125
126


























127
128



129
130
131
132
133
134
135
136
137
138
139
140
141
...
170
171
172
173
174
175
176






177
178

179

180
181
182
183
184
185
186
187
188
189
190
        set lw [font measure $font $line]
        if {$lw > $len} {
            set len $lw
        }
    }
    return $len
}



























proc psballoon::createBalloon {W mx my} {
    variable balloon



    if {$balloon(created) == 0} {
        # Figure out widget's font
        if {[catch {set font [$W cget -font]}]} {
            set font [ttk::style lookup [winfo class $W] -font]
        }
        # Fallback to something reasonable of font fails.
        if {$font eq ""} {
            set font TkDefaultFont
        }
        set ww [winfo width $W]
        set ih [winfo height $W]
        if {[winfo class $W] in {TLabelframe Labelframe}} {
            # Put it below the label, not the entire widget.
................................................................................
                set msg [subst -novariables -nobackslashes $msg]
            }
	    set iw [Measure $font $msg]
	}
	if {$create} {
            set x [expr {[winfo rootx $W] + $ix}]
            set y [expr {[winfo rooty $W] + $iy + $ih + 2}]






            if {$x + $iw + 8 > [winfo screenwidth $W]} {
                set x [expr {[winfo screenwidth $W] - $iw - 8}]

            }

            toplevel .balloon -bg black
            wm overrideredirect .balloon 1
            label .balloon.l \
                    -text $msg -relief flat -font $font -justify left \
                    -bg #ffffaa -fg black -padx 2 -pady 0 -anchor "w"
            pack .balloon.l -side left -padx 1 -pady 1
            wm geometry .balloon +${x}+${y}
            set balloon(created) 1
        }
    }
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>





|







 







>
>
>
>
>
>
|
<
>

>











119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212

213
214
215
216
217
218
219
220
221
222
223
224
225
226
        set lw [font measure $font $line]
        if {$lw > $len} {
            set len $lw
        }
    }
    return $len
}

# Returns a list of minX maxX for each screen.
# maxX are exclusive and normally equal to the next minX
proc psballoon::FigureOutScreenWidths {W} {
    set screens {}
    # Range of X over multiple windows
    set minX [winfo vrootx $W]
    set maxX [expr {$minX + [winfo vrootwidth $W]}]
    set sW [winfo screenwidth $W]

    # Guess: If minX is negative, there is a screen from minX to 0
    if {$minX < 0} {
	lappend screens $minX 0
    }
    # Guess: Main screen is in the middle if three

    # Main screen is 0 to screenWidth
    lappend screens 0 $sW

    # Guess: If maxX is larger than screen width (main screen), there
    # is one more screen to the right
    if {$maxX > $sW} {
	lappend screens $sW $maxX
    }
    return $screens
}

proc psballoon::createBalloon {W mx my} {
    variable balloon
    if {![winfo exists $W]} {
        return
    }
    if {$balloon(created) == 0} {
        # Figure out widget's font
        if {[catch {set font [$W cget -font]}]} {
            set font [ttk::style lookup [winfo class $W] -font]
        }
        # Fallback to something reasonable if font fails.
        if {$font eq ""} {
            set font TkDefaultFont
        }
        set ww [winfo width $W]
        set ih [winfo height $W]
        if {[winfo class $W] in {TLabelframe Labelframe}} {
            # Put it below the label, not the entire widget.
................................................................................
                set msg [subst -novariables -nobackslashes $msg]
            }
	    set iw [Measure $font $msg]
	}
	if {$create} {
            set x [expr {[winfo rootx $W] + $ix}]
            set y [expr {[winfo rooty $W] + $iy + $ih + 2}]
            # Limits of current screen.
            foreach {minX maxX} [FigureOutScreenWidths $W] {
                if {$minX <= $x && $x < $maxX} break
            }

            # Move it to the left as needed to fit on screen
            if {$x + $iw + 8 > $maxX} {

                set x [expr {$maxX - $iw - 8}]
            }
            # TBD, option to use a frame in parent instead?
            toplevel .balloon -bg black
            wm overrideredirect .balloon 1
            label .balloon.l \
                    -text $msg -relief flat -font $font -justify left \
                    -bg #ffffaa -fg black -padx 2 -pady 0 -anchor "w"
            pack .balloon.l -side left -padx 1 -pady 1
            wm geometry .balloon +${x}+${y}
            set balloon(created) 1
        }
    }
}