1 /***************************************************************************
2                           widget.h  -  Base-class for all GUI widgets
3                              -------------------
4     begin                : wo dec 15 2004
5     copyright            : (C) 2004 by CJP
6     email                : cornware-cjp@users.sourceforge.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17 
18 #ifndef WIDGET_H
19 #define WIDGET_H
20 
21 #define WIDGET_QUIT  		1
22 #define WIDGET_REDRAW		2
23 #define WIDGET_CANCELLED	4
24 
25 class CWidget {
26 public:
27 	CWidget();
28 	virtual ~CWidget();
29 
30 	virtual int onMouseMove(int x, int y, unsigned int buttons);
31 	virtual int onMouseClick(int x, int y, unsigned int buttons);
32 	virtual int onKeyPress(int key);
33 	virtual int onResize(int x, int y, int w, int h);
34 	virtual int onRedraw();
35 	virtual int onIdle();
36 
37 	bool isInWidget(int x, int y);
38 
getX()39 	int getX(){return m_X;}
getY()40 	int getY(){return m_Y;}
getW()41 	int getW(){return m_W;}
getH()42 	int getH(){return m_H;}
43 
44 	float m_Xrel, m_Yrel, m_Wrel, m_Hrel; //only for use by parent widget
45 protected:
46 	int m_X, m_Y, m_W, m_H;
47 
48 	void drawBackground();
49 
50 	//Scrollbar API:
51 	int m_RequestH; //negative = don't use scrollbar (default)
52 	int m_ScrollPosition;
53 
54 	int m_ScrollStartPos;
55 	float m_ScrollDistance;
56 
57 	void drawScrollbar();
58 	bool isInScrollbar(int x, int y);
59 	bool handleScrollbarMove(int x, int y, unsigned int buttons);
60 };
61 
62 #endif
63