File: title.h

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (42 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (3)
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
#ifndef GUI_PLOT_TITLE
#define GUI_PLOT_TITLE

#include <gtkmm/drawingarea.h>

class Title {
 public:
  Title()
      : _metricsAreInitialized(false),
        _plotWidth(0.0),
        _plotHeight(0.0),
        _topMargin(0.0),
        _fontSize(16),
        _height(0.0) {}
  void SetPlotDimensions(double plotWidth, double plotHeight,
                         double topMargin) {
    _plotWidth = plotWidth;
    _plotHeight = plotHeight;
    _topMargin = topMargin;
  }
  double GetHeight(const Cairo::RefPtr<Cairo::Context>& cairo) {
    initializeMetrics(cairo);
    return _height;
  }
  void Draw(const Cairo::RefPtr<Cairo::Context>& cairo);

  void SetText(const std::string& text) {
    _metricsAreInitialized = false;
    _text = text;
  }
  const std::string& Text() const { return _text; }

 private:
  void initializeMetrics(const Cairo::RefPtr<Cairo::Context>& cairo);

  bool _metricsAreInitialized;
  double _plotWidth, _plotHeight, _topMargin;
  double _fontSize, _height;
  std::string _text;
};

#endif