Welcome to mirror list, hosted at ThFree Co, Russian Federation.

button.hpp « gui - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c9f44082b37fba82ec420fed05f3141bca292913 (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
#pragma once

#include "gui/element.hpp"
#include "gui/text_view.hpp"

#include "std/function.hpp"
#include "std/string.hpp"
#include "std/unique_ptr.hpp"


namespace graphics
{
  class OverlayElement;
  class DisplayList;

  namespace gl
  {
    class OverlayRenderer;
  }
}

namespace gui
{
  class Button : public Element
  {
  public:
    typedef function<void (Element const *)> TOnClickListener;

  private:
    TOnClickListener m_OnClickListener;

    unsigned m_minWidth;
    unsigned m_minHeight;

    unique_ptr<TextView> m_textView;
    map<EState, unique_ptr<graphics::DisplayList> > m_dls;

    void cacheButtonBody(EState state);

  public:
    struct Params : Element::Params
    {
      unsigned m_minWidth;
      unsigned m_minHeight;
      string m_text;
      Params();
    };

    Button(Params const & p);

    void setOnClickListener(TOnClickListener const & l);

    void setFont(EState state, graphics::FontDesc const & font);
    void setColor(EState state, graphics::Color const & c);

    void setText(string const & text);
    string const & text() const;

    void setMinWidth(unsigned minWidthInDIP);
    unsigned minWidth() const;

    void setMinHeight(unsigned minHeightInDIP);
    unsigned minHeight() const;

    /// @name Override from graphics::OverlayElement and gui::Element.
    //@{
    virtual m2::RectD GetBoundRect() const;

    void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
    void setPivot(m2::PointD const & pv, bool dirtyFlag = true);

    void purge();
    void layout();
    void cache();

    void setController(Controller * controller);

    bool onTapStarted(m2::PointD const & pt);
    bool onTapMoved(m2::PointD const & pt);
    bool onTapEnded(m2::PointD const & pt);
    bool onTapCancelled(m2::PointD const & pt);
    //@}
  };
}