2015-10-29 21:10:50 +01:00
|
|
|
// File: keyboard.cpp
|
|
|
|
|
|
|
|
#include "final.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class keyboard
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class keyboard : public FWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit keyboard (FWidget* = 0);
|
|
|
|
protected:
|
|
|
|
void onKeyPress (FKeyEvent*);
|
|
|
|
void onAccel (FAccelEvent*);
|
2016-01-08 01:00:05 +01:00
|
|
|
void draw();
|
2015-10-29 21:10:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
keyboard::keyboard (FWidget* parent)
|
|
|
|
: FWidget(parent)
|
|
|
|
{
|
2016-01-08 01:00:05 +01:00
|
|
|
resetXTermForeground();
|
|
|
|
resetXTermBackground();
|
2016-01-10 00:56:52 +01:00
|
|
|
wc.term_fg = fc::Default;
|
|
|
|
wc.term_bg = fc::Default;
|
2015-10-29 21:10:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void keyboard::onKeyPress (FKeyEvent* ev)
|
|
|
|
{
|
|
|
|
int key_id = ev->key();
|
|
|
|
::printf("Key %s (id %d)\n\r", getKeyName(key_id).c_str(), key_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void keyboard::onAccel (FAccelEvent* ev)
|
|
|
|
{
|
|
|
|
quit();
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void keyboard::draw()
|
|
|
|
{
|
|
|
|
setNormal();
|
2016-01-10 00:56:52 +01:00
|
|
|
setColor(fc::Default, fc::Default);
|
2016-08-06 21:43:39 +02:00
|
|
|
clearArea();
|
2016-01-08 01:00:05 +01:00
|
|
|
gotoxy (1,1);
|
|
|
|
print ("---------------\n");
|
|
|
|
print ("Press Q to quit\n");
|
|
|
|
print ("---------------\n");
|
|
|
|
setCursorPos (1,5);
|
|
|
|
}
|
2015-10-29 21:10:50 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
FApplication app(argc, argv);
|
2016-01-08 01:00:05 +01:00
|
|
|
keyboard key(&app);
|
|
|
|
key.addAccelerator('q');
|
|
|
|
app.setMainWidget(&key);
|
|
|
|
key.show();
|
2015-10-29 21:10:50 +01:00
|
|
|
return app.exec();
|
|
|
|
}
|