From 8addcbbcb7efefba9cbb7e81efe3c631ed0c5b2f Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 14 Jan 2018 21:53:45 +0100 Subject: [PATCH] Mouse functions are now in a separate class --- .gitignore | 1 + include/final/fapplication.h | 2 +- include/final/fmouse.h | 97 +++++++++++++++--------------------- src/fmouse.cpp | 28 ++++++++++- 4 files changed, 70 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index 73594396..13427fec 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.gcov *.gcno *.gcda +stamp-h1 _configs.sed config.guess config.h.in~ diff --git a/include/final/fapplication.h b/include/final/fapplication.h index aef95249..63086ab6 100644 --- a/include/final/fapplication.h +++ b/include/final/fapplication.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2013-2017 Markus Gans * +* Copyright 2013-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * diff --git a/include/final/fmouse.h b/include/final/fmouse.h index 099c6f79..74b2f71b 100644 --- a/include/final/fmouse.h +++ b/include/final/fmouse.h @@ -199,7 +199,7 @@ class FMouseGPM : public FMouse virtual ~FMouseGPM(); // Accessors - const char* getClassName() const; + virtual const char* getClassName() const; // Mutators void setStdinNo(int); @@ -238,10 +238,6 @@ class FMouseGPM : public FMouse #pragma pack(pop) #endif -//---------------------------------------------------------------------- -inline const char* FMouseGPM::getClassName() const -{ return "FMouseGPM"; } - //---------------------------------------------------------------------- inline bool FMouseGPM::enableGpmMouse() { return gpmMouse(true); } @@ -272,7 +268,7 @@ class FMouseX11 : public FMouse virtual ~FMouseX11(); // Accessors - const char* getClassName() const; + virtual const char* getClassName() const; // Inquiry virtual bool hasData(); @@ -317,10 +313,6 @@ class FMouseX11 : public FMouse }; #pragma pack(pop) -//---------------------------------------------------------------------- -inline const char* FMouseX11::getClassName() const -{ return "FMouseX11"; } - //---------------------------------------------------------------------- // class FMouseSGR @@ -339,7 +331,7 @@ class FMouseSGR : public FMouse virtual ~FMouseSGR(); // Accessors - const char* getClassName() const; + virtual const char* getClassName() const; // Inquiry virtual bool hasData(); @@ -384,10 +376,6 @@ class FMouseSGR : public FMouse }; #pragma pack(pop) -//---------------------------------------------------------------------- -inline const char* FMouseSGR::getClassName() const -{ return "FMouseSGR"; } - //---------------------------------------------------------------------- // class FMouseUrxvt @@ -406,7 +394,7 @@ class FMouseUrxvt : public FMouse virtual ~FMouseUrxvt(); // Accessors - const char* getClassName() const; + virtual const char* getClassName() const; // Inquiry virtual bool hasData(); @@ -451,10 +439,6 @@ class FMouseUrxvt : public FMouse }; #pragma pack(pop) -//---------------------------------------------------------------------- -inline const char* FMouseUrxvt::getClassName() const -{ return "FMouseUrxvt"; } - //---------------------------------------------------------------------- // class FMouseControl @@ -472,50 +456,49 @@ class FMouseControl virtual ~FMouseControl(); // Accessors - const char* getClassName() const; - FPoint& getPos(); - void clearEvent(); + virtual const char* getClassName() const; + FPoint& getPos(); + void clearEvent(); // Mutators - void setStdinNo (int); - void setMaxWidth (short); - void setMaxHeight (short); - void useGpmMouse (bool = true); - void useXtermMouse (bool = true); + void setStdinNo (int); + void setMaxWidth (short); + void setMaxHeight (short); + void useGpmMouse (bool = true); + void useXtermMouse (bool = true); // Inquiries - bool hasData(); - bool hasEvent(); - bool isLeftButtonPressed(); - bool isLeftButtonReleased(); - bool isLeftButtonDoubleClick(); - bool isRightButtonPressed(); - bool isRightButtonReleased(); - bool isMiddleButtonPressed(); - bool isMiddleButtonReleased(); - bool isShiftKeyPressed(); - bool isControlKeyPressed(); - bool isMetaKeyPressed(); - bool isWheelUp(); - bool isWheelDown(); - bool isMoved(); - bool isInputDataPending(); - bool isGpmMouseEnabled(); + bool hasData(); + bool hasEvent(); + bool isLeftButtonPressed(); + bool isLeftButtonReleased(); + bool isLeftButtonDoubleClick(); + bool isRightButtonPressed(); + bool isRightButtonReleased(); + bool isMiddleButtonPressed(); + bool isMiddleButtonReleased(); + bool isShiftKeyPressed(); + bool isControlKeyPressed(); + bool isMetaKeyPressed(); + bool isWheelUp(); + bool isWheelDown(); + bool isMoved(); + bool isInputDataPending(); + bool isGpmMouseEnabled(); // Methods - void enable(); - void disable(); - void xtermMouse (bool); - void enableXTermMouse(); - void disableXTermMouse(); - virtual void setRawData (FMouse::mouse_type, char[], int); - virtual void processEvent (struct timeval* time); - bool getGpmKeyPressed (bool); - void drawGpmPointer(); + void enable(); + void disable(); + void xtermMouse (bool); + void enableXTermMouse(); + void disableXTermMouse(); + virtual void setRawData (FMouse::mouse_type, char[], int); + virtual void processEvent (struct timeval* time); + bool getGpmKeyPressed (bool); + void drawGpmPointer(); private: - std::map mouse_protocol; - std::map::iterator iter; + // Accessor FMouse* getMouseWithData(); @@ -523,6 +506,8 @@ class FMouseControl void putstring (const char[], int = 1); // Data Member + std::map mouse_protocol; + std::map::iterator iter; FPoint zero_point; bool use_gpm_mouse; bool use_xterm_mouse; diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 75fcd3a1..01685549 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -238,6 +238,12 @@ FMouseGPM::~FMouseGPM() // destructor // public methods of FMouseX11 +//---------------------------------------------------------------------- +const char* FMouseGPM::getClassName() const +{ + return "FMouseGPM"; +} + //---------------------------------------------------------------------- void FMouseGPM::setStdinNo (int file_descriptor) { @@ -459,6 +465,12 @@ FMouseX11::~FMouseX11() // destructor // public methods of FMouseX11 +//---------------------------------------------------------------------- +const char* FMouseX11::getClassName() const +{ + return "FMouseX11"; +} + //---------------------------------------------------------------------- bool FMouseX11::hasData() { @@ -653,6 +665,12 @@ FMouseSGR::~FMouseSGR() // destructor // public methods of FMouseSGR +//---------------------------------------------------------------------- +const char* FMouseSGR::getClassName() const +{ + return "FMouseSGR"; +} + //---------------------------------------------------------------------- bool FMouseSGR::hasData() { @@ -896,6 +914,12 @@ FMouseUrxvt::~FMouseUrxvt() // destructor // public methods of FMouseUrxvt +//---------------------------------------------------------------------- +const char* FMouseUrxvt::getClassName() const +{ + return "FMouseUrxvt"; +} + //---------------------------------------------------------------------- bool FMouseUrxvt::hasData() { @@ -1148,7 +1172,9 @@ void FMouseUrxvt::setButtonState (int button, struct timeval* time) // constructors and destructor //---------------------------------------------------------------------- FMouseControl::FMouseControl() - : zero_point(0,0) + : mouse_protocol() + , iter() + , zero_point(0,0) , use_gpm_mouse(false) , use_xterm_mouse(false) {