2019-11-13 13:37:49 +01:00
|
|
|
#ifndef LIBRARY_VKVM_HPP
|
|
|
|
#define LIBRARY_VKVM_HPP
|
|
|
|
|
|
|
|
#include "Color.hpp"
|
|
|
|
#include "EventType.hpp"
|
|
|
|
#include "FontType.hpp"
|
2019-11-13 15:42:04 +01:00
|
|
|
#include "GraphicMode.hpp"
|
2019-11-13 13:37:49 +01:00
|
|
|
#include "KeyCode.hpp"
|
|
|
|
#include "LayoutVersion.hpp"
|
|
|
|
#include "log.hpp"
|
2019-11-12 14:07:02 +01:00
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
2019-10-23 17:12:04 +02:00
|
|
|
|
2019-11-13 13:37:49 +01:00
|
|
|
namespace vkvm {
|
|
|
|
/**
|
2019-10-23 17:12:04 +02:00
|
|
|
* @since 0.1.0
|
|
|
|
* @author Johannes Theiner
|
|
|
|
*/
|
|
|
|
|
2019-11-13 13:37:49 +01:00
|
|
|
struct Coordinates {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
};
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize the connection with the shared-memory application
|
|
|
|
* @param pid pip of shared-memory application
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto initialize(int pid) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
2019-11-12 16:25:57 +01:00
|
|
|
|
2019-10-23 17:12:04 +02:00
|
|
|
/**
|
|
|
|
* set pixel at a x,y position to a certain color.
|
|
|
|
* @param x x coordinate of pixel
|
|
|
|
* @param y y coordinate of pixel
|
|
|
|
* @param color color of pixel
|
|
|
|
* @return true if operation succeeded, false if it failed.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setPixel(int x, int y, Color color) -> bool;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get color of pixel at x,y position
|
|
|
|
* @param x x coordinate of pixel
|
|
|
|
* @param y y coordinate of pixel
|
|
|
|
* @return color of pixel
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getPixel(int x, int y) -> Color;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* register handler for event.
|
|
|
|
* @param type type of event.
|
|
|
|
* @param handler function to call.
|
|
|
|
* @return true if handler could be registered, false if it failed.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto registerEvent(EventType type, const std::function<void()> &handler) -> bool;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set displayed text in Text mode
|
|
|
|
* @param text text to display
|
|
|
|
* @return if text could be set, false if it could not be set.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setText(std::string text) -> bool;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get currently saved/displayed text.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getText() -> std::string;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
2019-12-01 19:56:35 +01:00
|
|
|
/**
|
|
|
|
* clear text area
|
|
|
|
* @return if text could be cleared, false if it could not be cleared.
|
|
|
|
*/
|
|
|
|
auto clearText() -> bool;
|
|
|
|
|
|
|
|
|
2019-10-23 17:12:04 +02:00
|
|
|
//Control registers start here
|
|
|
|
|
|
|
|
//all modes
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get version of the used layout
|
|
|
|
* @return layout version
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getLayoutVersion() -> LayoutVersion;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* reset all values to default.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto reset() -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get width of window.
|
|
|
|
* @return width of window.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getWidth() -> int;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set width of window.
|
|
|
|
* @param newValue new width for window.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setWidth(int newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get height for window.
|
|
|
|
* @return height of window.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getHeight() -> int;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set height of window.
|
|
|
|
* @param newValue new height for window.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setHeight(int newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get graphics display mode.
|
|
|
|
* @return GraphicMode.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getMode() -> GraphicMode;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set new graphics display mode.
|
|
|
|
* @param newValue new graphics display mode.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setMode(GraphicMode newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get interval between redraws in milliseconds.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getRedrawInterval() -> int;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set interval between redraws.
|
|
|
|
* @param newValue new interval in milliseconds.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setRedrawInterval(int newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get time between timer interrupts.
|
|
|
|
* @return time between interrupts in milliseconds.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getTimerInterruptInterval() -> int;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set time between timer interrupts.
|
|
|
|
* @param newValue new time between interrupts in milliseconds.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setTimerInterruptInterval(int newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
//black/white mode
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get background color in two color mode.
|
|
|
|
* @return background color.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getBackgroundColor() -> Color;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set background color in two color mode.
|
|
|
|
* @param newValue new background color.
|
|
|
|
*/
|
2019-11-27 13:39:16 +01:00
|
|
|
auto setBackgroundColor(const Color &newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get foreground color in two color mode.
|
|
|
|
* @return foreground color.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getForegroundColor() -> Color;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set foreground color in two color mode.
|
|
|
|
* @param newValue new foreground color.
|
|
|
|
*/
|
2019-11-27 13:39:16 +01:00
|
|
|
auto setForegroundColor(const Color &newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
//text mode
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get characters per row in text mode.
|
|
|
|
* @return characters per row.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getCharactersPerRow() -> int;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
2019-10-29 15:24:57 +01:00
|
|
|
/**
|
|
|
|
* get characters per column in text mode.
|
|
|
|
* @return characters per column.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getCharactersPerColumn() -> int;
|
2019-10-29 15:24:57 +01:00
|
|
|
|
2019-10-23 17:12:04 +02:00
|
|
|
/**
|
|
|
|
* get currently used font in text mode.
|
|
|
|
* @return currently used font.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getFont() -> FontType;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set text mode font.
|
|
|
|
* @param newValue new text mode font.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto setFont(const FontType &newValue) -> void;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get current mouse position
|
|
|
|
* @return mouse position as x,y pair
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getMousePosition() -> Coordinates;
|
2019-10-23 17:12:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get key code of last key press.
|
|
|
|
* @return KeyCode of last key press.
|
|
|
|
*/
|
2019-11-13 13:37:49 +01:00
|
|
|
auto getLastPressedKey() -> KeyCode;
|
|
|
|
}
|
2019-10-21 18:39:55 +02:00
|
|
|
|
|
|
|
#endif
|