00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ZONEMAP_H
00022 #define ZONEMAP_H
00023
00024 #include "stylusnormalizer.h"
00025
00026 #include <qlist.h>
00027 #include <qscrollview.h>
00028 #include <qstring.h>
00029
00030 extern const int iCITYOFFSET;
00031
00032 class QImage;
00033 class QComboBox;
00034 class QLabel;
00035 class QTimer;
00036 class QToolButton;
00037 class QListViewItem;
00038 class QListView;
00039
00040
00041 class ZoneField
00042 {
00043 public:
00044 ZoneField( const QString & );
00045 void showStructure( void ) const;
00046 inline int x( void ) const { return _x; };
00047 inline int y( void ) const { return _y; };
00048
00049 inline QString city( void ) const { return strCity; };
00050 inline QString country( void ) const { return strCountry; };
00051 inline QString code( void ) const { return strCountryCode; };
00052 private:
00053 int _x;
00054 int _y;
00055 QString strCountryCode;
00056 QString strCountry;
00057 QString strCity;
00058 };
00059
00060 class ZoneMap : public QScrollView
00061 {
00062 Q_OBJECT
00063 public:
00064 ZoneMap( QWidget *parent = 0, const char *name = 0 );
00065 ~ZoneMap();
00066 void showZones( void ) const;
00067 QWidget* selectionWidget( QWidget* parent );
00068
00069
00070 inline bool zoneToWin( int zoneX, int zoneY, int &winX, int &winY ) const;
00071 inline bool winToZone( int winX, int winY, int &zoneX, int &zoneY ) const;
00072
00073 public slots:
00074 void slotZoom( bool setZoom );
00075 void slotIllum( bool setIllum );
00076 void slotUpdate( void );
00077 void slotRedraw( void );
00078 void slotFindCity( const QPoint &pos );
00079 void changeClock( bool );
00080
00081 signals:
00082 void signalTz( const QString &newCountry, const QString &newCity );
00083
00084 protected:
00085 virtual void viewportMouseMoveEvent( QMouseEvent *event );
00086 virtual void viewportMousePressEvent( QMouseEvent *event );
00087 virtual void viewportMouseReleaseEvent( QMouseEvent *event );
00088 virtual void keyPressEvent( QKeyEvent * );
00089 virtual void resizeEvent( QResizeEvent *);
00090 virtual void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
00091
00092 private slots:
00093 void slotGetCities( QListViewItem * );
00094 void slotCitySelected( QListViewItem * );
00095 private:
00096 ZoneField *findCityNear( ZoneField *city, int key );
00097 void showCity( ZoneField *city );
00098 void drawCities( QPainter *p );
00099 void drawCity( QPainter *p, const ZoneField *pCity );
00100 void readZones( void );
00101 void zoom( void );
00102 void makeMap( int width, int height );
00103 QPixmap* pixCurr;
00104 QLabel* lblCity;
00105 QToolButton *cmdZoom;
00106 QTimer* tHide;
00107 ZoneField *pLast;
00108 ZoneField *pRepaint;
00109 QList<ZoneField> zones;
00110 StylusNormalizer norm;
00111
00112 QListView *cityView;
00113 QString selectedCont;
00114
00115
00116 int wImg;
00117 int hImg;
00118
00119 int ox;
00120 int oy;
00121
00122
00123 int drawableW;
00124 int drawableH;
00125
00126 bool bZoom;
00127 bool bIllum;
00128 bool ampm;
00129
00130 ZoneField *cursor;
00131 };
00132
00133 inline bool ZoneMap::zoneToWin( int zoneX, int zoneY,
00134 int &winX, int &winY ) const
00135 {
00136 winY = oy - ( ( hImg * zoneY ) / 648000 );
00137 winX = ox + ( ( wImg * zoneX ) / 1296000 );
00138
00139 if ( winX > wImg ) {
00140 winX = wImg - iCITYOFFSET;
00141 } else if ( winX <= 0 ) {
00142 winX = iCITYOFFSET;
00143 }
00144
00145 if ( winY >= hImg ) {
00146 winY = hImg - iCITYOFFSET;
00147 } else if ( winY <= 0 ) {
00148 winY = iCITYOFFSET;
00149 }
00150
00151
00152 return true;
00153 }
00154
00155 inline bool ZoneMap::winToZone( int winX, int winY,
00156 int &zoneX, int &zoneY ) const
00157 {
00158 zoneY = ( 648000 * ( oy - winY ) ) / hImg;
00159 zoneX = ( 1296000 * ( winX - ox ) ) / wImg;
00160
00161
00162 return true;
00163 }
00164
00165 #endif