B15F
Board 15 Famulus Edition
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
View Class Referenceabstract

#include <view.h>

+ Inheritance diagram for View:

Public Member Functions

 View (void)
 
virtual ~View (void)
 
virtual void setTitle (std::string title)
 
virtual void repaint (void)
 
virtual void draw (void)=0
 
virtual call_t keypress (int &key)=0
 

Static Public Member Functions

static void setWinContext (WINDOW *win)
 
static WINDOW * getWinContext (void)
 
static std::vector< std::string > str_split (const std::string &str, const std::string delim)
 

Protected Attributes

int width
 width of view in terminal characters
 
int height
 height of view in terminal characters
 
int start_x = 0
 x offset (characters) in the terminal, used to center the window on repaint()
 
int start_y = 0
 y offset (characters) in the terminal, used to center the window on repaint()
 
std::string title
 title of the view
 
std::vector< call_t > calls
 calls (function pointers) for different button actions in the view (if any)
 

Static Protected Attributes

static WINDOW * win = nullptr
 static window contexts for all views
 
constexpr static int KEY_ENT = 10
 Key value for the Enter key.
 

Detailed Description

Base class for multiple views with the ncurses user interface.

Definition at line 19 of file view.h.

Constructor & Destructor Documentation

◆ View()

View::View ( void  )

standard constructor, takes no args

Definition at line 5 of file view.cpp.

◆ ~View()

View::~View ( void  )
virtual

standard destructor

Definition at line 15 of file view.cpp.

Member Function Documentation

◆ draw()

virtual void View::draw ( void  )
pure virtual

Abstract function for drawing ths particular view. Gets overridden in the derived classes to paints for example a promt.

Implemented in ViewInfo, ViewPromt, and ViewSelection.

◆ getWinContext()

WINDOW * View::getWinContext ( void  )
static
Returns
static window context for all views

Definition at line 24 of file view.cpp.

◆ keypress()

virtual call_t View::keypress ( int &  key)
pure virtual

Abstract function for the view to reacted on a keypress. Gets overridden in the derived classes to close for example a view on ESC.

Implemented in ViewInfo, ViewMonitor, ViewPromt, and ViewSelection.

◆ repaint()

void View::repaint ( void  )
virtual

Repaints the whole window with the current view. The centered position of the window in the terminal gets new calculated. The window box gets repainted.

Definition at line 52 of file view.cpp.

◆ setTitle()

void View::setTitle ( std::string  title)
virtual

Sets the title of this view

Parameters
titlestring to set title

Definition at line 47 of file view.cpp.

◆ setWinContext()

void View::setWinContext ( WINDOW *  win)
static

Sets static view context, used for every view Note: this UI systems supports only one window

Parameters
winwindow context

Definition at line 19 of file view.cpp.

◆ str_split()

std::vector< std::string > View::str_split ( const std::string &  str,
const std::string  delim 
)
static

Splits a string by a delimeter and returns the parts in a vector

Parameters
strinput string
delimthe delimeter for splitting
Returns
splitted parts of str

Definition at line 30 of file view.cpp.


The documentation for this class was generated from the following files: