comments for ui/view.h
This commit is contained in:
parent
9640bb00c8
commit
3b71364edf
112 changed files with 1746 additions and 437 deletions
|
@ -1,4 +1,4 @@
|
|||
#ifndef COMMIT_HASH_H
|
||||
#define COMMIT_HASH_H
|
||||
const char COMMIT_HASH[] = "28277098cbdeb228c0fcb0c04394643f6fd15a20";
|
||||
const char COMMIT_HASH[] = "9640bb00c8b16073af9eadf9e40ede3c2e0e4020";
|
||||
#endif // COMMIT_HASH_H
|
||||
|
|
|
@ -10,25 +10,40 @@
|
|||
class DriverException: public std::exception
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param message as c-string
|
||||
*/
|
||||
explicit DriverException(const char* message) : msg_(message)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param message as c++-string
|
||||
*/
|
||||
explicit DriverException(const std::string& message) : msg_(message)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard-destructor
|
||||
*/
|
||||
virtual ~DriverException() throw ()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get failure description
|
||||
* @return error message as c-string
|
||||
*/
|
||||
virtual const char* what() const throw ()
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string msg_;
|
||||
std::string msg_; //!< failure description
|
||||
};
|
||||
|
||||
#endif // DRIVEREXCEPTION_H
|
||||
|
|
|
@ -65,42 +65,43 @@ public:
|
|||
|
||||
/**
|
||||
* Sets the stepwith the parameter got increased with each curve.
|
||||
* \param para_first parameter stepwith
|
||||
* \param para_stepwidth parameter stepwith
|
||||
*/
|
||||
void setParaStepWidth(uint16_t para_stepwidth);
|
||||
|
||||
/**
|
||||
* Sets the unit of the x axis.
|
||||
* \param para_first unit
|
||||
* \param unit_x unit identifier
|
||||
*/
|
||||
void setUnitX(std::string unit_x);
|
||||
|
||||
/**
|
||||
* Sets the description of the x axis.
|
||||
* \param para_first description
|
||||
* \param desc_x description
|
||||
*/
|
||||
void setDescX(std::string desc_x);
|
||||
|
||||
/**
|
||||
* Sets the unit of the y axis.
|
||||
* \param para_first unit
|
||||
* \param unit_y unit identifier
|
||||
*/
|
||||
void setUnitY(std::string unit_y);
|
||||
|
||||
/**
|
||||
* Sets the description of the y axis.
|
||||
* \param para_first description
|
||||
* \param desc_y description
|
||||
*/
|
||||
void setDescY(std::string desc_y);
|
||||
|
||||
/**
|
||||
* Sets the unit of the parameter.
|
||||
* \param para_first unit
|
||||
* \param unit_para unit identifier
|
||||
*/
|
||||
void setUnitPara(std::string unit_para);
|
||||
|
||||
/**
|
||||
* Sets the description of the parameter.
|
||||
* \param para_first description
|
||||
* \param desc_para description
|
||||
*/
|
||||
void setDescPara(std::string desc_para);
|
||||
|
||||
|
@ -112,7 +113,7 @@ public:
|
|||
FunctionType getFunctionType(void) const;
|
||||
|
||||
/**
|
||||
* \return the quadrant
|
||||
* \return the quadrant number
|
||||
*/
|
||||
uint8_t getQuadrant(void) const;
|
||||
|
||||
|
@ -183,7 +184,7 @@ private:
|
|||
|
||||
std::vector<Dot> dots;
|
||||
|
||||
int8_t command = 0x1D;
|
||||
int8_t command = 0x1D; //!< command for file header
|
||||
const std::string head = "HTWK-HWLab";
|
||||
const std::string filetype = "MD";
|
||||
int16_t version = 1;
|
||||
|
@ -200,7 +201,7 @@ private:
|
|||
std::string desc_y; //!< description for y-axis
|
||||
std::string unit_para; //!< unit name for parameter
|
||||
std::string desc_para; //!< description for parameter
|
||||
const uint8_t eof = 0xD;
|
||||
const uint8_t eof = 0xD; //!< end of file, but only marks end of header
|
||||
|
||||
constexpr static uint8_t STR_LEN_SHORT = 10; //!< string length for short string in header
|
||||
constexpr static uint8_t STR_LEN_LARGE = 20; //!< string length for large string in header
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
* Constructor
|
||||
* @param message as c-string
|
||||
*/
|
||||
explicit TimeoutException(const char* message) : msg(message)
|
||||
explicit TimeoutException(const char* message) : msg_(message)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
* Constructor
|
||||
* @param message as c++-string
|
||||
*/
|
||||
explicit TimeoutException(const std::string& message) : msg(message)
|
||||
explicit TimeoutException(const std::string& message) : msg_(message)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ public:
|
|||
*/
|
||||
virtual const char* what() const throw ()
|
||||
{
|
||||
return msg.c_str();
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string msg; //!< failure description
|
||||
std::string msg_; //!< failure description
|
||||
};
|
||||
|
||||
#endif // TIMEOUTEXCEPTION_H
|
||||
|
|
|
@ -19,29 +19,72 @@ typedef std::function<void(int)> call_t;
|
|||
class View
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* standard constructor, takes no args
|
||||
*/
|
||||
View(void);
|
||||
|
||||
/**
|
||||
* standard destructor
|
||||
*/
|
||||
virtual ~View(void);
|
||||
|
||||
/**
|
||||
* Sets static view context, used for every view
|
||||
* Note: this UI systems supports only one window
|
||||
* \param win window context
|
||||
*/
|
||||
static void setWinContext(WINDOW* win);
|
||||
|
||||
/**
|
||||
* \return static window context for all views
|
||||
*/
|
||||
static WINDOW* getWinContext(void);
|
||||
|
||||
/**
|
||||
* Splits a string by a delimeter and returns the parts in a vector
|
||||
* \param str input string
|
||||
* \param delim the delimeter for splitting
|
||||
* \return splitted parts of str
|
||||
*/
|
||||
static std::vector<std::string> str_split(const std::string& str, const std::string delim);
|
||||
|
||||
/**
|
||||
* Sets the title of this view
|
||||
* \param title string to set title
|
||||
*/
|
||||
virtual void setTitle(std::string title);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
virtual void repaint(void);
|
||||
|
||||
/**
|
||||
* Abstract function for drawing ths particular view.
|
||||
* Gets overridden in the derived classes to paints for example a promt.
|
||||
*/
|
||||
virtual void draw(void) = 0;
|
||||
|
||||
/**
|
||||
* Abstract function for the view to reacted on a keypress.
|
||||
* Gets overridden in the derived classes to close for example a view on ESC.
|
||||
*/
|
||||
virtual call_t keypress(int& key) = 0;
|
||||
|
||||
|
||||
protected:
|
||||
int width, height;
|
||||
int start_x = 0, start_y = 0;
|
||||
std::string title;
|
||||
std::vector<call_t> calls;
|
||||
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 WINDOW* win;
|
||||
constexpr static int KEY_ENT = 10;
|
||||
static WINDOW* win; //!< static window contexts for all views
|
||||
constexpr static int KEY_ENT = 10; //!< Key value for the Enter key
|
||||
};
|
||||
|
||||
#endif // VIEW_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue