Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas) 
Author Message
 Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas)

[PRELIMINARY NOTE: along this message
I'll refer to "interface.png". This
archive explains itself what I need,
but through this newsgroup I can
put it for your eyes. Don't worry:
if you response me in my e-mail address,
I'll can send it.]

   I need do (in TCL/TK) the graphic part of a
program (please, look at top of "interface.png"
to understand what I want). I have just begin
in know about TCL/TK, so I don't know how to
implement it. Because of this, I need

  YOU PROGRAM IN tcl/tk THE SOLUTION FOR ME

I'd rather a Visual Tcl Project solution, but a
solution written manually by you in TCL is also
good for me.

   As you can see in top figure of
"interface.png", there is a graphic
representation of the messages exchanged
between objects; it's an UML sequence diagram,
plus an indication of in what instant the
message was sent. For example:
    The object "o9" of class "C5" calls
    to "o7.do_something()" (= "o9" sends
    the message "do_something()" to
    "o7"). This occurs on instant 6
    miliseconds.

   The program that I want (call it
"solution.tcl") has an unique point of entry:
a procedure (call it "receiveEvent") that
takes 3 arguments:
   - the name of the sender object
   - the message
   - the name of the receiver object
All of them are strings.
An external program (it may be a Java program,
a C program, or a TCL program) calls to
"receiveEvent" whenever it wants. [YOU DON'T
CARE ABOUT THIS EXTERNAL PROGRAM; YOU ONLY
MUST ENABLE THE "receiveEvent", AND KNOW THAT
WHEN IT IS CALLED, POSSIBLY YOU MUST REDRAW
THE DISPLAY TO REFLECT THAT AN MESSAGE-EVENT
HAS SUCEED].

   Now, look at bottom figure of
"interface.png". This figure is the top figure
divided into canvas (some of them are SCROLLED
CANVAS). The following aspects that I'm going
to explain are THE MOST IMPORTANT of the
program that I want.

* When HSB is moved left/right:

     - Objects Area moves left/right. This cause
       that some objects appear on display and
       some other objects disappear of display.    

     - Messages Area moves left/right AT TE SAME
       TIME THAT ObjectsArea (synchronized with
       ObjectsArea). This cause that some messages
       appear on display and some other messages
       dissapear of display.

     - Times Area remains static, without changes.

* When VSB is moved up/down:

     - Objects Area remains static, without changes.

     - Messages Area moves up/down AT TE SAME TIME
       THAT Times Area (synchronized with
       TimesArea). This cause that some messages
       appear on display and some other messages
       dissapear of display.      

     - Times Area moves up/down. This cause that
       some time values appear on display and some
       other disappear of display.

The last requirements (also VERY IMPORTANT):

* No message must be lost. The solution must react
  quickly to "receiveEvent" call and redraw the
  display (if it proceeds), etc.

* Must be possible that the scrolled frame "Messages
  Area" had an INFINITY CAPACITY: whenever an event
  arrives, the VSB indicator must move towards down
  and canvas must enlarge its capacity. It's
  similar to a text editor wich can load a big
  archive and the user can scroll down to view any
  part of the archive. Horizontally, the canvas is
  not going to grown very much because the number
  of objects is fixed in each execution (doesn't
  grown) and because there is only one message per
  line, BUT it's desirable that your solution
  don't crash when a message is too large o when
  the time indicator exceed to 2 digits; in both
  cases, MessagesArea and TimesArea should be
  ENLARGED HORIZONTALLY.

* The space between consecutive horizontal lines
  is fixed (is always the same).

* Each message is placed on its arrow and in the
  middle of the arrow (how is showed in the
  figure).

Please, with your "solution.tcl" send me also another
program (in TCL is good) to prove your solution. A
small program that calls successively to "receiveEvent".

Finally, and taking a bit of advantage (don't do the
following if you don't want), I would like a Java
version of your solution.

  ====================================
      PLEASE, SEND ME A MESSAGE TO

    IF YOU ARE PREPARED TO DOING IT
  ====================================



Mon, 23 May 2005 02:14:56 GMT  
 Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas)
        ... [need for multi-widget scrolling] ...

The answer to this is in the Tk faq.  It references listboxes, but the
technique applies to any scrollable Tk widgets:
        http://tcl.sourceforge.net/faqs/tk/#listbox/multiple

You will find that this is much more difficult in Java.

--
     Jeff Hobbs                     The Tcl Guy
     Senior Developer               http://www.ActiveState.com/
         Tcl Support and Productivity Solutions



Tue, 24 May 2005 01:23:03 GMT  
 Two canvas scrolled simultaneously by the same scrollbar (an UNIQUE scrollbar and TWO or more canvas)

Quote:
>    Now, look at bottom figure of
> "interface.png". This figure is the top figure
> divided into canvas (some of them are SCROLLED
> CANVAS). The following aspects that I'm going
> to explain are THE MOST IMPORTANT of the
> program that I want.

> * When HSB is moved left/right:

>      - Objects Area moves left/right. This cause
>        that some objects appear on display and
>        some other objects disappear of display.    

>      - Messages Area moves left/right AT TE SAME
>        TIME THAT ObjectsArea (synchronized with
>        ObjectsArea). This cause that some messages
>        appear on display and some other messages
>        dissapear of display.

>      - Times Area remains static, without changes.

> * When VSB is moved up/down:

>      - Objects Area remains static, without changes.

>      - Messages Area moves up/down AT TE SAME TIME
>        THAT Times Area (synchronized with
>        TimesArea). This cause that some messages
>        appear on display and some other messages
>        dissapear of display.      

>      - Times Area moves up/down. This cause that
>        some time values appear on display and some
>        other disappear of display.

The following code permits three canvases stacked horizontally to scroll.
The three canveses are: objects canvas, messages canvas, times canvas.
The horizontal scrollings of objects and messages canvases are synchronized.
The vertical scrollings of messages and times canvases are synchronized.

  # create the canvases

  foreach cnv {obj msg time} \
  {
    grid [canvas .$cnv -width 200 -height 100] -pady 1
    for {set i 0} {$i < 10} {incr i} \
    {
      for {set j 0} {$j < 10} {incr j} \
      {
        .$cnv create text [expr {$i * 50}] [expr {$j * 50}] -text $cnv-$i-$j
      }
    }
    .$cnv config -scroll [.$cnv bbox all]
  }

  # create the scroll bars

  scrollbar .hsb -orient horizontal -command xview
  scrollbar .vsb -orient vertical -command yview
  grid .hsb -sticky we
  grid .vsb -sticky ns -row 0 -column 2 -rowspan 3

  # tie the scroll bars to the messages canvas

  .msg config -xscrollcommand {.hsb set}
  .msg config -yscrollcommand {.vsb set}

  # proc to scroll horizontally .obj & .msg

  proc xview {args} \
  {
    eval .obj xview $args
    eval .msg xview $args
  }

  # proc to scroll vertically .msg & .time

  proc yview {args} \
  {
    eval .msg yview $args
    eval .time yview $args
  }
  . config -bg beige

HTH

ulis



Tue, 24 May 2005 07:10:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Scrollbar to control two canvas widgets simultaneously

2. help with scrolling two listboxes by the single scrollbar

3. Scrolling two different widgets will one scrollbar

4. Scrolling two listboxes with one scrollbar?

5. How to scroll (horizontal) 2 canvas widgets with the same scrollbar

6. Two canvases (widgets), one scrollbar..

7. SYNCHRONIZED SCROLLING, or, ONE SCROLLBAR TO SCROLL 2CanvasesWindows

8. tk4.0/scrollbar.tcl and scrollbar widget delta

9. ListBox / ScrollBar: Fire Event on Scroll

10. Scroll - what|where exactly wire widget and scrollbar?

11. scrollbar unwanted multiple scrolls

12. Scrollbar does not scroll !!

 

 
Powered by phpBB® Forum Software