[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    Slider(3X) manual page Table of Contents

Name

Slider - scroll an interactor’s perspective in two dimensions

Synopsis

#include <ivplus/panner.h>

Description

Slider is an interactor that manipulates the perspective of another interactor. A slider lets the user specify the visible portion of the view. A bevelled rectangle represents the visible area, while the area surrounding it represents the total area. Clicking and holding down any mouse button on the rectangle allows you to drag it to a different position within the total area. The perspective’s current origin is shifted to reflect the new position. Holding down the shift key while dragging the rectangle constrains its motion horizontally or vertically. Clicking outside the rectangle moves it in the corresponding one of eight directions. For example, clicking to the right of the rectangle moves it to the right. Slider is only used by the Panner class.

Class Hierarchy

Slider->Interactor

Constructors

Slider(Interactor*)

Slider(const char* intanceName, Interactor*)

Create a slider to manipulate the perspective of the given interactor.

Public Operations

virtual void Draw()

Draws the slider on the canvas. Called when an Interactor::Redraw() is performed.

virtual void Handle(Event&)

Handles input events to the slider.

virtual void Reshape(Shape&)

Sets the width of the slider to that of the passed Shape and calls Change() on the parent interactor.

virtual void Resize()

Notifies the slider that its canvas has been created or modified.

virtual void Update()

Redisplays the slider to reflect a change in the interactor’s perspective.

Protected

virtual void Reconfig()

Creates a new painter for use with the slider, then checks to see if a value has been set for the syncScroll X resource. If so, it evaluates this value and sets the member variable syncScroll to the result (true or false).

virtual void Redraw(IntCoord left, IntCoord bottom, IntCoord right, IntCoord top)

Calls Clip() on the canvas with the passed coordinates to limit the Draw() operation to the visible area of the canvas. Then Draw() is called followed by NoClip().

X Defaults

None.

Examples


//                          Slider Example
#include <ivplus/box.h>
#include <ivplus/frame.h>
#include <ivplus/glue.h>
#include <ivplus/panner.h>
#include <ivplus/shape.h>
#include <ivplus/textbuffer.h>
#include <ivplus/mltexteditor.h>
#include <ivplus/world.h>
#include <string.h>
static const char* sample = "Slider Example Line1\n 
   This is Line 2\nThis is Line 3\nThis is Line 4\n IntCoord top)"
   This is Line 5\nThis is Line 6\nThis is Line 7\n IntCoord top)"
   This is Line 8\nThis is Line 9\nThis is Line 10\n IntCoord top)"
   This is Line 11\nThis is Line 12\nThis is Line 13\n IntCoord top)"
   This is a very loooooooooooooooooooooooooooooooong line line  Line 14";
    
int main(int argc, char **argv)
{
   const int BuffSize = 512;
   char* buf = new char[BuffSize];
   // Create the world to get the connection with the display.
   World* world = new World("MyApp", argc, argv);
   // Create a text editor to give Slider a perspective
   strcpy(buf, sample);
   TextBuffer* tbuf= new TextBuffer(buf, strlen(buf), BuffSize);
   // Create a text editor with 10 rows, 25 cols, and tabsize=8.
   MLTextEditor* tedit = new MLTextEditor(10, 25, 8);
   tedit->Edit(tbuf);
   // Create a slider with tedit as Interactor to manipulate.
   Slider* slider = new Slider(tedit);
   // Create a new shape of width=100, height=150.
   Shape shape;
   shape.width = 100;
   shape.height = 150;
   // Set the horizontal and vertical shrinkability to 10, 
   // horizontal and vertical stretchability to maximum.
   shape.Rigid(10, hfil, 10, vfil);
  
   // Set the slider’s shape to the one just created.
   slider->Reshape(shape);
   
   // Compose an hbox with this text editor, glue, and the slider.
   HBox* appbox = new HBox(tedit, new HGlue(4, 0, 0), 
                           new VBox(new VGlue,slider));
   // Map the window.
   world->InsertApplication(new Frame(appbox, 1, BevelOut));
   // Enter the event loop.
   world->Run();
   return 0;
}

Files


panner.h 
panner.C 

See Also

Interactor(3X) , Panner(3X) , Perspective(3X) .


Table of Contents