HELP: Scrollbar information with the "get" command 
Author Message
 HELP: Scrollbar information with the "get" command

I have a problem related to the scrollbar information you get with the
"pathname get" command. The manual page says "These are the values from
the most recent set widget command on the scrollbar". My question is if
there's a way to get the updated values from this command without
executing the "update" command first, since "update" also causes the
canvas to be unnecessary redrawn.

Background:
-----------
I have an application where I'm scrolling and zooming a canvas. To zoom,
I use the "scale" command, but after that I need to issue xview and yview
commands to scroll automatically, so that center in the visible part of the
canvas remains the same as before the zoom.

Now I have code that does just that. It is based on reading the status of
the scrollbars before and after the scale with the "pathname get" command
and from this computing the automatic scrolling needed to preserve the
center. The disadvantage is that I need to issue an "update" command after
the scale to get the new "pathname get" info. This means the canvas is redrawn
before the automatic scroll, and then immediately redrawn after the scrolling.
I want to avoid the canvas from being drawn twice. But how?

A code example:
---------------
Definitions in main routine:
   canvas .t.frame.t.canv -scrollregion "${x_s}c ${_y_s}c ${x_e}c ${y_e}c \
           -xscroll ".t.frame.b.hscroll set" -yscroll ".t.frame.t.vscroll set"

   scrollbar .t.frame.t.vscroll -relief sunken \
              -command ".t.frame.t.canv yview"
   scrollbar .t.frame.b.hscroll -orient horiz -relief sunken \
              -command ".t.frame.t.canv xview"

Zoom routine (parts of code):
   set w .t.frame.t.canv

  # Using get command to get scrollbar info before scale
   set xtot_o [lindex [.t.frame.b.hscroll get] 0]
   .
   puts [.t.frame.b.hscroll get]         (Here: 59 58 0 59)
   .                                     ------------------
  # Scaling with lattice upper corner as origo
   $w scale all $scroll_x_start $scroll_y_start 2 2
   .
   # Setting the new scrollregion
   $w configure -scrollregion $regbounds
   .
   puts [.t.frame.b.hscroll get]         (Here: Still 59 58 0 59)
   update                                ------------------------
   puts [.t.frame.b.hscroll get]         (Here: Now: 113 57 0 58)
   .                                      ------------------------
  # Using get command to get scrollbar info after scale
   set xtot_n [lindex [.t.frame.b.hscroll get] 0]
   .
   .
  # Automatic scrolling to center picture
   $w xview...

I want the [.t.frame.b.hscroll get] to be updated without having to use
the "update" command. Can the update command be replaced by something else,
or can the problem be solved another way? (By the way, this is Tcl7.3/Tk3.6).


 --

Consultant, Software Development                Phone: +47 63 81 49 20
Division for Nuclear and Petroleum Engineering  Fax: +47 63 81 88 22
Scandpower A/S, International Consultants       Address: P.O. Box 3
--                                              N-2007 Kjeller, NORWAY



Tue, 12 May 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Scrollbar information with the "get" command

2. "gets" help needed

3. Re "gets" help needed

4. Help: Case of the Wandering "GETS"

5. Help Getting "mspdbX0.dll" for HLA

6. Help wanted: "Menu to" command

7. Need help: "invalid command tcl_findLibrary"

8. need help with "python" command

9. HELP with "exec" command

10. Q: help with "entry" command

11. Q: help with using "pack" command

12. "unknown" command HELP

 

 
Powered by phpBB® Forum Software