summaryrefslogtreecommitdiffstats
path: root/grapher/CairoWidget.hxx
blob: 32d92cce8f76d04e3005892e509815451486583f (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
// systemtap grapher
// Copyright (C) 2009 Red Hat Inc.
//
// This file is part of systemtap, and is free software.  You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.

#ifndef SYSTEMTAP_CAIROWIDGET_H
#define SYSTEMTAP_CAIROWIDGET_H 1

#include <cairomm/context.h>
namespace systemtap
{
class CairoWidget
{
public:
  CairoWidget(bool visible = false)
    : _visible(visible)
  {}
  bool isVisible() const { return _visible; }
  void setVisible(bool visible) { _visible = visible; }
  void getOrigin(double &x, double &y) const
  {
    x = _x0;
    y = _y0;
  }
  void setOrigin(double x, double y)
  {
    _x0 = x;
    _y0 = y;
  }
  virtual void draw(Cairo::RefPtr<Cairo::Context> cr) = 0;
  virtual bool containsPoint(double x, double y) { return false; }
protected:
  bool _visible;
  double _x0;
  double _y0;
};

class CairoPlayButton : public CairoWidget
{
public:
  CairoPlayButton(bool visible = false)
    : CairoWidget(visible), _size(50.0), _radius(5)
  {
  }
  virtual void draw(Cairo::RefPtr<Cairo::Context> cr);
  virtual bool containsPoint(double x, double y);
protected:
  double _size;
  double _radius;
};

class CairoTextBox : public CairoWidget
{
public:
  void draw(Cairo::RefPtr<Cairo::Context> cr);
  std::string contents;
};
}
#endif