30.11.2013 - New PICollection namespace, Android support, my own PIVector implementation

This commit is contained in:
peri4
2013-11-30 19:34:53 +04:00
parent ec5530053a
commit f50891b376
64 changed files with 5466 additions and 3392 deletions

View File

@@ -1,5 +1,5 @@
/*! \file pikbdlistener.h
* \brief Keyboard console input listerner
* \brief Keyboard console input listener
*/
/*
PIP - Platform Independent Primitives
@@ -32,54 +32,82 @@
typedef void (*KBFunc)(char, void * );
/// events:
/// keyPressed(char key, void * data)
///
/// handlers:
/// void enableExitCapture(char key = 'Q')
/// void setActive(bool yes = true)
class PIP_EXPORT PIKbdListener: public PIThread
{
PIOBJECT(PIKbdListener)
friend class PIConsole;
public:
//! Special keyboard keys
enum SpecialSymbol {
UpArrow = -1,
DownArrow = -2,
RightArrow = -3,
LeftArrow = -4,
CtrlUpArrow = -5,
CtrlDownArrow = -6,
CtrlRightArrow = -7,
CtrlLeftArrow = -8
UpArrow /** Up arrow key */ = -1,
DownArrow /** Down arrow key */ = -2,
RightArrow /** Right arrow key */ = -3,
LeftArrow /** Left arrow key */ = -4,
CtrlUpArrow /** Ctrl + Up arrow key */ = -5,
CtrlDownArrow /** Ctrl + Down arrow key */ = -6,
CtrlRightArrow /** Ctrl + Right arrow key */ = -7,
CtrlLeftArrow /** Ctrl + Left arrow key */ = -8
};
// slot is any function format "void <func>(char, void * )"
//! Constructs keyboard listener with external function "slot" and custom data "data"
PIKbdListener(KBFunc slot = 0, void * data = 0);
~PIKbdListener() {terminate(); end();}
//! Set custom data to "data"
void setData(void * data_) {data = data_;}
void setSlot(KBFunc slot_) {ret_func = slot_;}
//! Set external function to "slot"
void setSlot(KBFunc slot) {ret_func = slot;}
//! Returns if exit key if awaiting
bool exitCaptured() const {return exit_enabled;}
//! Returns exit key, default 'Q'
char exitKey() const {return exit_key;}
//! Returns if keyboard listening is active (not running!)
bool isActive() {return is_active;}
EVENT_HANDLER( void, enableExitCapture) {enableExitCapture('Q');}
EVENT_HANDLER1(void, enableExitCapture, char, key) {exit_enabled = true; exit_key = key;}
void disableExitCapture() {exit_enabled = false;}
bool exitCaptured() const {return exit_enabled;}
char exitKey() const {return exit_key;}
bool isActive() {return is_active;}
EVENT_HANDLER(void, disableExitCapture) {exit_enabled = false;}
EVENT_HANDLER(void, setActive) {setActive(true);}
EVENT_HANDLER1(void, setActive, bool, yes);
EVENT2(keyPressed, char, key, void * , data)
//! \handlers
//! \{
//! \fn void enableExitCapture(char key = 'Q')
//! \brief Enable exit key "key" awaiting
//! \fn void disableExitCapture()
//! \brief Disable exit key awaiting
//! \fn void setActive(bool yes = true)
//! \brief Set keyboard listening is active or not
//! \}
//! \events
//! \{
//! \fn void keyPressed(char key, void * data)
//! \brief Raise on key "key" pressed, "data" is custom data
//! \}
static bool exiting;
private:
void begin();
void run();
void end();
void raiseSpecial();
KBFunc ret_func;
char exit_key;
bool exit_enabled, is_active;