2 /**************************************************************************
3 ** (c) Copyright 1998, Andromeda Technology & Automation
4 ***************************************************************************
5 ** MODULE INFORMATION *
6 ***********************
7 ** FILE NAME : scroll.h
8 ** SYSTEM NAME : AXE - Andromeda X-windows Encapsulation
9 ** VERSION NUMBER : $Revision: 1.1 $
11 ** DESCRIPTION : Definition of scrollbar class.
12 ** A scrollbar is a construction with two frames. The
13 ** scrollbar itself and a slider that moves within
19 ***************************************************************************
20 ** ADMINISTRATIVE INFORMATION *
21 ********************************
22 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
23 ** CREATION DATE : Mar 20, 1998
24 ** LAST UPDATE : Oct 09, 1999
26 **************************************************************************/
28 /*****************************
30 Revision 1.1 2002-07-25 08:01:27 arjen
31 First checkin, AXE release 0.2
33 *****************************/
35 /* static const char *RCSID = "$Id: scroll.h,v 1.1 2002-07-25 08:01:27 arjen Exp $"; */
45 ///////////////////////////////////////////////////////////////////////////
56 // LAST MODIFIED : Oct 09, 1999
57 ///////////////////////////////////////////////////////////////////////////
60 class slider : public frame
70 virtual int EV_ButtonPress(XButtonEvent ev)
77 virtual int EV_ButtonRelease(XButtonEvent ev)
82 virtual int EV_MotionNotify(XMotionEvent ev);
86 ///////////////////////////////////////////////////////////////////////////
94 // The bar_size, slider_size and position are defined
95 // in logical coordinates.
96 // The bar_size represents the size of the data being
97 // scrolled and corresponds to the total size of the
98 // scrollbar. The slider_size and position are mapped to
99 // physical coordinates using the ratio of the bar_size.
101 // physical coord = logical coord * window size / bar size.
105 // LAST MODIFIED : Apr 03, 1998
106 ///////////////////////////////////////////////////////////////////////////
109 class scrollbar : public frame
113 unsigned bar_size, slider_size;
119 scrollbar(window &par, unsigned size, int x, int y)
120 : frame(par, x, y, -2)
125 sl = new slider(this);
127 SelectInput(ButtonPressMask, 1);
135 // Map physical pixel coordinate to logical coordinate.
137 int map_mouse(int mouse)
139 size scroll_size = Size();
142 physical = mouse * (int)bar_size / scroll_size.h;
147 void move_slider(int offset);
149 virtual int EV_ButtonPress(XButtonEvent ev)
151 if (map_mouse(ev.y) > position)
152 move_slider(slider_size);
154 move_slider(-slider_size);
164 void SetSizes(unsigned s_bar, unsigned s_slider);
167 #endif /* _SCROLL_H */