summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/mapcanvas.h
blob: 9be7cf842b5397f3f2a36a959e01ea545702fdc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/***************************************************************************
                          mapcanvas.h  -  K Desktop Planetarium
                             -------------------
    begin                : Tue Apr 10 2001
    copyright            : (C) 2001 by Jason Harris
    email                : jharris@30doradus.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/




#ifndef MAPCANVAS_H
#define MAPCANVAS_H

#include <tqwidget.h>
#include <tqpoint.h>

/**@class MapCanvas
	*Used in LocationDialog for displaying a map of the Earth.
	*In addition, cities in the database are drawn as grey or white dots.
	*Also, the widget processes mouse clicks, to trim the list of
	*cities to those near the mouse click.
	*@short Widget used in the LocationDialog for displaying the world map.
	*@author Jason Harris
	*@version 1.0
	*/

class TQPixmap;

class MapCanvas : public TQWidget  {
	Q_OBJECT
  
public: 
	/**Default constructor.  Initialize the widget: create pixmaps, load the
		*world map bitmap, set pointers to the main window and the
		*LocationDialog parent.
		*/
	MapCanvas(TQWidget *parent=0, const char *name=0);
	/**Destructor (empty)
		*/
	~MapCanvas();
	
public slots:
	/**Set the geometry of the map widget (overloaded from TQWidget).
		*Resizes the size of the map pixmap to match the widget, and resets
		*the Origin TQPoint so it remains at the center of the widget.
		*@note this is called automatically by resize events.
		*@p x the x-position of the widget
		*@p y the y-position of the widget
		*@p w the width of the widget
		*@p h the height of the widget
		*/
	virtual void setGeometry( int x, int y, int w, int h );
	
	/**Set the geometry of the map widget (overloaded from TQWidget).
		*Resizes the size of the map pixmap to match the widget, and resets
		*the Origin TQPoint so it remains at the center of the widget.
		*This function behaves just like the above function.  It differs
		*only in the data type of its argument.
		*@note this is called automatically by resize events.
		*@p r TQRect describing geometry
		*/
	virtual void setGeometry( const TQRect &r );

protected:
	/**Draw the map.  Draw grey dots on the locations of all cities, 
		*and highlight the cities which match the current filters 
		*as white dits.  Also draw a red crosshairs on the 
		*currently-selected city.
		*@see LocationDialog
		*/
	virtual void paintEvent( TQPaintEvent *e );
	
	/**Trim the list of cities so that only those within 2 degrees
		*of the mouse click are shown in the list.
		*@see LocationDialog
		*/
	virtual void mousePressEvent( TQMouseEvent *e );

private:
	TQPixmap *Canvas, *bgImage;
	TQString BGColor;
	TQPoint origin;
};

#endif