graph_analysis
MarginArea.hpp
Go to the documentation of this file.
1 #ifndef TOOLS_GRAPH_ANALYSIS_GUI_MARGIN_AREA_HPP
2 #define TOOLS_GRAPH_ANALYSIS_GUI_MARGIN_AREA_HPP
3 
4 #include <QWidget>
5 
6 namespace graph_analysis {
7 namespace gui {
8 
9 class GraphWidget;
10 
11 class MarginArea : public QWidget
12 {
13 public:
14  enum Type { None = 0x00, Top = 0x01, Bottom = 0x02, Left = 0x04, Right = 0x08 };
15 
16  MarginArea(GraphWidget* widget, Type type)
17  : QWidget(widget)
18  , mpGraphWidget(widget)
19  , mType(type)
20  {
21  }
22 
23  QSize sizeHint() const
24  {
25  switch(mType)
26  {
27  case Left:
28  case Right:
29  // mpGraphWidget->leftMarginAreaWidth()
30  return QSize(50, 0);
31  case Top:
32  case Bottom:
33  // mpGraphWidget->topMarginAreaWidth()
34  return QSize(0, 50);
35  case None:
36  default:
37  throw std::runtime_error("graph_analysis::gui::MarginArea::sizeHint: given MarginArea type is not supported");
38  }
39  }
40 
41 protected:
42  void paintEvent(QPaintEvent* event)
43  {
44  QPainter painter(this);
45  switch(mType)
46  {
47  case Left:
48  painter.fillRect(event->rect(), Qt::red);
49  painter.drawText(0,50,50,20, Qt::AlignLeft, "LEFT");
50  break;
51  case Right:
52  painter.fillRect(event->rect(), Qt::blue);
53  painter.drawText(0,50,50,20, Qt::AlignRight, "RIGHT");
54  break;
55  case Top:
56  painter.fillRect(event->rect(), Qt::yellow);
57  painter.drawText(50,0,50,20, Qt::AlignTop, "TOP");
58  break;
59  case Bottom:
60  painter.fillRect(event->rect(), Qt::green);
61  painter.drawText(50,0,50,20, Qt::AlignBottom, "BOTTOM");
62  break;
63  case None:
64  default:
65  break;
66  }
67  // mpGraphWidget->leftMarginAreaPaintEvent()
68  }
69 
70 private:
71  GraphWidget* mpGraphWidget;
72  Type mType;
73 
74 };
75 
76 } // end namespace gui
77 } // end namespace graph_analysis
78 #endif // TOOLS_GRAPH_ANALYSIS_GUI_MARGIN_AREA_HPP
MarginArea(GraphWidget *widget, Type type)
Definition: MarginArea.hpp:16
Definition: MarginArea.hpp:14
Type
Definition: MarginArea.hpp:14
Definition: MarginArea.hpp:11
Base-class for visual representations of a "Graph" in this framework.
Definition: GraphWidget.hpp:26
Definition: MarginArea.hpp:14
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
void paintEvent(QPaintEvent *event)
Definition: MarginArea.hpp:42
QSize sizeHint() const
Definition: MarginArea.hpp:23
Definition: MarginArea.hpp:14
Definition: MarginArea.hpp:14
Definition: MarginArea.hpp:14