using FbTk's new EventHandler interface

This commit is contained in:
fluxgen 2002-11-27 21:56:56 +00:00
parent 97a2ea9d23
commit 43c4469119
2 changed files with 48 additions and 41 deletions

View file

@ -19,11 +19,12 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbRun.cc,v 1.7 2002/11/26 17:13:36 fluxgen Exp $
// $Id: FbRun.cc,v 1.8 2002/11/27 21:56:56 fluxgen Exp $
#include "FbRun.hh"
#include "App.hh"
#include "EventManager.hh"
#include <X11/Xlib.h>
#include <X11/keysym.h>
@ -48,6 +49,7 @@ m_current_history_item(0) {
FbRun::~FbRun() {
hide();
FbTk::EventManager::instance()->unregisterEventHandler(m_win);
XDestroyWindow(m_display, m_win);
}
@ -70,7 +72,7 @@ void FbRun::run(const std::string &command) {
else
cerr<<"FbRun Warning: Can't write command history to file: "<<m_history_file<<endl;
}
FbTk::App::instance()->end(); // end application
m_end = true; // mark end of processing
}
@ -193,6 +195,8 @@ void FbRun::createWindow(int x, int y, size_t width, size_t height) {
XSelectInput(m_display, m_win, KeyPressMask|ExposureMask);
FbTk::EventManager::instance()->registerEventHandler(*this, m_win);
setNoMaximize();
m_width = width;
@ -200,12 +204,10 @@ void FbRun::createWindow(int x, int y, size_t width, size_t height) {
}
void FbRun::handleEvent(XEvent * const xev) {
switch (xev->type) {
case KeyPress: {
void FbRun::keyPressEvent(XKeyEvent &ke) {
KeySym ks;
char keychar[1];
XLookupString(&xev->xkey, keychar, 1, &ks, 0);
XLookupString(&ke, keychar, 1, &ks, 0);
if (ks == XK_Escape) {
m_end = true;
hide();
@ -233,13 +235,10 @@ void FbRun::handleEvent(XEvent * const xev) {
}
redrawLabel();
}
} break;
case Expose:
}
void FbRun::exposeEvent(XExposeEvent &ev) {
redrawLabel();
break;
default:
break;
}
}
void FbRun::getSize(size_t &width, size_t &height) {

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbRun.hh,v 1.6 2002/11/15 14:03:14 fluxgen Exp $
// $Id: FbRun.hh,v 1.7 2002/11/27 21:56:02 fluxgen Exp $
#ifndef FBRUN_HH
#define FBRUN_HH
@ -33,7 +33,7 @@
/**
Creates and managed a run window
*/
class FbRun: public FbTk::EventHandler<XEvent> {
class FbRun: public FbTk::EventHandler {
public:
FbRun(int x = 0, int y = 0, size_t width = 200);
~FbRun();
@ -63,6 +63,14 @@ public:
@return true on success, else false
*/
bool loadHistory(const char *filename);
/**
@name events
*/
///@{
void exposeEvent(XExposeEvent &ev);
void keyPressEvent(XKeyEvent &ev);
///@}
private:
void nextHistoryItem();
void prevHistoryItem();