-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlocationwidget.h
More file actions
61 lines (41 loc) · 1.28 KB
/
locationwidget.h
File metadata and controls
61 lines (41 loc) · 1.28 KB
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
#ifndef LOCATIONWIDGET_H
#define LOCATIONWIDGET_H
//#include <QWidget>
#include <QtGui>
#include <assert.h>
#include <time.h>
#include "maptilesframe.h"
namespace Ui {
class LocationWidget;
}
class MapTilesFrame;
class LocationWidget : public QWidget
{
Q_OBJECT
public:
explicit LocationWidget(QWidget *parent, QPoint serverCoordinate = QPoint());
~LocationWidget();
void moveToServerCoordinate(QPoint newPosition);
void setServerCoordinate(QPoint newPosition);
QPoint getServerCoordinate() const;
QPoint getRelativeCoordinate(int scaleLevel) const;
QPoint getRandomPos() const;
QPoint getTrulyRandomPos() const;
QPoint setRandomPos();
static const QPoint offset;
void setPixmap(const QPixmap& pixmap);
private:
Ui::LocationWidget *ui;
QPoint m_serverPos;
MapTilesFrame *mapFrame;
//我们需要隐藏下面两个接口,这样就让本控件只能通过设置服务器坐标系坐标来更新位置,而不能通过其他方法
void move(const QPoint &point);
void setGeometry(const QRect &);
protected:
void mousePressEvent(QMouseEvent *event);
signals:
void serverCoordinateChanged(QPoint newPos, QPoint oldPos);
public slots:
void checkVisibility();
};
#endif // LOCATIONWIDGET_H