PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Primitive/MainApp/crosshair.h

https://bitbucket.org/flexcomputer/primitive
C Header | 50 lines | 35 code | 12 blank | 3 comment | 0 complexity | bf591017c09aad456dd99faa64326715 MD5 | raw file
 1#ifndef CROSSHAIR_H
 2#define CROSSHAIR_H
 3
 4#include <QObject>
 5#include <QPainter>
 6
 7// The crosshair class
 8
 9class Crosshair : public QObject
10{
11    Q_OBJECT
12public:
13    explicit Crosshair(QObject *parent = 0);
14
15    // States
16    enum State {
17        MainSelect = 0,
18        PickPoint = 1,
19        SelectObject = 2,
20        Hidden = 3
21    };
22
23    // Get/set functions
24    virtual int x() const { return _x; }
25    virtual int y() const { return _y; }
26    virtual QString prompt() const { return _prompt; }
27    virtual State state() const { return _state; }
28    virtual bool showPrompt() const { return _showPrompt; }
29
30    virtual void setX(int x) { _x = x; }
31    virtual void setY(int y) { _y = y; }
32    virtual void setPrompt(QString prompt) { _prompt = prompt; }
33    virtual void setState(State state) { _state = state; }
34    virtual void setShowPrompt(bool show = true) { _showPrompt = show; }
35
36    virtual void paintAt(QPainter& painter);
37
38protected:
39    int _x, _y; // The position of the crosshair
40    QString _prompt; // The crosshair's prompt
41    State _state; // The crosshair's state
42    bool _showPrompt; // True - draw the prompt
43
44signals:
45
46public slots:
47
48};
49
50#endif // CROSSHAIR_H