aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/AsciiRenderer.cpp100
-rw-r--r--src/ui/AsciiRenderer.hpp37
-rw-r--r--src/ui/Window.cpp20
-rw-r--r--src/ui/Window.hpp9
4 files changed, 22 insertions, 144 deletions
diff --git a/src/ui/AsciiRenderer.cpp b/src/ui/AsciiRenderer.cpp
deleted file mode 100644
index d06dadb..0000000
--- a/src/ui/AsciiRenderer.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Renderer.cpp
- *
- * Created on: Nov 23, 2017
- * Author: naopross
- */
-
-#include "AsciiRenderer.hpp"
-
-#include <memory>
-
-namespace samb {
-
-AsciiRenderer::AsciiRenderer(Structogram& structogram, unsigned int width):
- m_structogram(structogram), m_width(width) {}
-
-AsciiRenderer::~AsciiRenderer() {}
-
-void AsciiRenderer::drawPadding(unsigned int amt) {
- while (amt--) {
- std::cout << " ";
- }
-}
-
-void AsciiRenderer::drawLine() const {
- for (unsigned int i = 0; i < m_width; i++) {
- std::cout << "-";
- }
-
- std::cout << std::endl;
-}
-
-void AsciiRenderer::drawText(std::string text, unsigned int width, std::string before, std::string after) const {
-
- if (width == 0) {
- width = m_width;
- }
-
- unsigned int textWidth = width - before.length() - after.length();
-
- std::cout << before;
- for (std::size_t i = 0; i < text.length(); i++) {
- if (i % textWidth == 0 && i != 0) {
- std::cout << after << "\n" << before;
- }
-
- std::cout << text[i];
- }
-
- std::cout << std::endl;
-}
-
-void AsciiRenderer::drawDecision(std::string condition, std::string trueText, std::string falseText, unsigned int width) const {
- if (width == 0) {
- width = m_width -2;
- }
-
- std::cout << "|";
-
-// drawPadding(width - condition.length());
-}
-
-void AsciiRenderer::render() {
-
- for (Structogram::iterator it = m_structogram.begin(); it != m_structogram.end(); ++it) {
-
- switch (it->type) {
- case Statement::Type::PROCESS:
- drawLine();
- drawText(it->text);
- drawLine();
- break;
-
- case Statement::Type::DECISION:
- break;
-
- case Statement::Type::SWITCH:
- break;
-
- case Statement::Type::SCOPE:
- std::cout << "Title: " << it->text << std::endl;
- break;
-
- case Statement::Type::WHILE:
- break;
-
- case Statement::Type::UNTIL:
- break;
-
- case Statement::Type::PARALLEL:
- break;
-
- case Statement::END:
- // do nothing
- break;
- }
- }
-}
-
-} /* namespace samb */
diff --git a/src/ui/AsciiRenderer.hpp b/src/ui/AsciiRenderer.hpp
deleted file mode 100644
index 76d6ff5..0000000
--- a/src/ui/AsciiRenderer.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Renderer.h
- *
- * Created on: Nov 23, 2017
- * Author: naopross
- */
-
-#ifndef SRC_UI_ASCIIRENDERER_HPP_
-#define SRC_UI_ASCIIRENDERER_HPP_
-
-#include "../diagram/Structogram.hpp"
-
-namespace samb {
-
-/* Sample renderer for debug,
- *
- * TODO: implement PdfRenderer, UiRenderer with a common interface
- */
-class AsciiRenderer {
-private:
- Structogram m_structogram;
- const unsigned int m_width;
-
- void drawPadding(unsigned int amt);
- void drawLine() const;
- void drawText(std::string text, unsigned int width = 0, std::string before = "|", std::string after = "|") const;
- void drawDecision(std::string condition, std::string trueText, std::string falseText, unsigned int width = 0) const;
-public:
- AsciiRenderer(Structogram& structogram, unsigned int width);
- ~AsciiRenderer();
-
- void render();
-};
-
-} /* namespace samb */
-
-#endif /* SRC_UI_ASCIIRENDERER_HPP_ */
diff --git a/src/ui/Window.cpp b/src/ui/Window.cpp
index 4572766..e3d5b52 100644
--- a/src/ui/Window.cpp
+++ b/src/ui/Window.cpp
@@ -7,15 +7,29 @@
#include "Window.hpp"
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QApplication>
+
+
namespace samb {
-Window::Window() {
- // TODO Auto-generated constructor stub
+Window::Window(QWidget *parent): QWidget(parent) {
+ setWindowTitle("OrbitingYeti");
+
+ QVBoxLayout *vBox = new QVBoxLayout(this);
+ QHBoxLayout *hBox = new QHBoxLayout();
+ m_quitBtn = new QPushButton("Quit", this);
+ connect(m_quitBtn, SIGNAL(clicked()), qApp, SLOT(quit()));
+
+ hBox->addWidget(m_quitBtn, 0, Qt::AlignRight);
+ vBox->addStretch(1);
+ vBox->addLayout(hBox);
}
Window::~Window() {
- // TODO Auto-generated destructor stub
+
}
} /* namespace samb */
diff --git a/src/ui/Window.hpp b/src/ui/Window.hpp
index 5afad8c..9b04ebb 100644
--- a/src/ui/Window.hpp
+++ b/src/ui/Window.hpp
@@ -9,17 +9,18 @@
#define SRC_UI_WINDOW_HPP_
#include <QWidget>
+#include <QPushButton>
namespace samb {
class Window : public QWidget {
Q_OBJECT
public:
- Window();
- virtual ~Window();
+ explicit Window(QWidget *parent = 0);
+ ~Window();
-signals:
-public slots:
+private:
+ QPushButton *m_quitBtn;
};
} /* namespace samb */