NTK 1.3.0
Fl_Panzoomer.H
1
2/*******************************************************************************/
3/* Copyright (C) 2012 Jonathan Moore Liles */
4/* */
5/* This program is free software; you can redistribute it and/or modify it */
6/* under the terms of the GNU General Public License as published by the */
7/* Free Software Foundation; either version 2 of the License, or (at your */
8/* option) any later version. */
9/* */
10/* This program is distributed in the hope that it will be useful, but WITHOUT */
11/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
13/* more details. */
14/* */
15/* You should have received a copy of the GNU General Public License along */
16/* with This program; see the file COPYING. If not,write to the Free Software */
17/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18/*******************************************************************************/
19
20#ifndef Fl_Panzoomer_H
21#define Fl_Panzoomer_H
22
23#include <FL/Fl_Valuator.H>
24
25class FL_EXPORT Fl_Panzoomer : public Fl_Valuator
26{
27protected:
28
29 int _zoom;
30 bool _zoom_changed;
31 int _zoom_min;
32 int _zoom_max;
33
34 double _ymin, _ymax, _xmin, _xmax;
35 double _xpos, _ypos;
36
37 /* size of the window vertically and horizontally as a value
38 * between 0-1. */
39 double _ysize, _xsize;
40
41protected:
42
43 virtual void draw_cursor ( int X, int Y, int W, int H );
44 /* override this method to draw a thumbnail background... */
45 virtual void draw_background ( int X, int Y, int W, int H );
46 virtual void draw ( int X, int Y, int W, int H );
47 virtual int handle ( int m, int X, int Y, int W, int H );
48 void cursor_bounds ( int &cx, int &cy, int &cw, int &ch ) const;
49
50public:
51
52 virtual void draw ( void );
53 virtual int handle ( int m );
54
55 Fl_Panzoomer ( int X, int Y, int W, int H, const char *L=0 );
56 virtual ~Fl_Panzoomer ( ) { }
57
58 /* these behave like Fl_Scrollbar::value() */
59 /* first and total are the bounds, size is the size of the window,
60 * and pos is the leftmost edge. */
61 int x_value ( int pos, int size, int first, int total );
62 int y_value ( int pos, int size, int first, int total );
63
64 double x_value ( void ) const { return _xpos; }
65 double y_value ( void ) const { return _ypos; }
66 void x_value ( double v );
67 void y_value ( double v );
68
69
70 bool zoom_changed ( void ) const { return _zoom_changed; }
71 double zoom ( void ) const { return _zoom; }
72 void zoom ( int v );
73
74 void zoom_range ( int zmin, int zmax ) { _zoom_min = zmin; _zoom_max = zmax; }
75
76 void zoom_in ( void ) { int z = _zoom; zoom( _zoom - 1 ); if ( z != _zoom ) do_callback(); }
77 void zoom_out ( void ) { int z = _zoom; zoom( _zoom + 1 ); if ( z != _zoom ) do_callback(); }
78};
79
80#endif
Definition: Fl_Panzoomer.H:26
The Fl_Valuator class controls a single floating-point value and provides a consistent interface to s...
Definition: Fl_Valuator.H:55
virtual void draw()=0
Draws the widget.
void do_callback()
Calls the widget callback.
Definition: Fl_Widget.H:837
virtual int handle(int event)
Handles the specified event.
Definition: Fl_Widget.cxx:106