2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fevent.cpp - Base event class of widgets *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-11-21 20:07:08 +01:00
|
|
|
* Copyright 2014-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fevent.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-09-22 04:18:20 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FEvent::FEvent (fc::events ev_type) // constructor
|
2018-12-03 03:22:36 +01:00
|
|
|
: t{ev_type}
|
2015-09-22 04:18:20 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FEvent::~FEvent() // destructor
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-24 18:11:16 +01:00
|
|
|
fc::events FEvent::type() const
|
2015-09-22 04:18:20 +02:00
|
|
|
{ return t; }
|
|
|
|
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FKeyEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
2018-12-03 03:22:36 +01:00
|
|
|
, k{key_num}
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FKeyEvent::~FKeyEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-11-21 20:07:08 +01:00
|
|
|
FKey FKeyEvent::key() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{ return k; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FKeyEvent::isAccepted() const
|
|
|
|
{ return accpt; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FKeyEvent::accept()
|
|
|
|
{ accpt = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FKeyEvent::ignore()
|
|
|
|
{ accpt = false; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMouseEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
2015-09-22 04:18:20 +02:00
|
|
|
, const FPoint& pos
|
2018-12-03 03:22:36 +01:00
|
|
|
, const FPoint& termPos
|
2015-09-22 04:18:20 +02:00
|
|
|
, int button )
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
2018-12-03 03:22:36 +01:00
|
|
|
, p{pos}
|
|
|
|
, tp{termPos}
|
|
|
|
, b{button}
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-24 18:11:16 +01:00
|
|
|
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
2015-09-22 04:18:20 +02:00
|
|
|
, const FPoint& pos
|
|
|
|
, int button )
|
2018-12-03 03:22:36 +01:00
|
|
|
: FMouseEvent(ev_type, pos, FPoint(), button)
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FMouseEvent::~FMouseEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const FPoint& FMouseEvent::getPos() const
|
|
|
|
{ return p; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
const FPoint& FMouseEvent::getTermPos() const
|
|
|
|
{ return tp; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FMouseEvent::getX() const
|
|
|
|
{ return p.getX(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FMouseEvent::getY() const
|
|
|
|
{ return p.getY(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
int FMouseEvent::getTermX() const
|
|
|
|
{ return tp.getX(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
int FMouseEvent::getTermY() const
|
|
|
|
{ return tp.getY(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FMouseEvent::getButton() const
|
|
|
|
{ return b; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FWheelEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
2015-09-22 04:18:20 +02:00
|
|
|
, const FPoint& pos
|
2018-12-03 03:22:36 +01:00
|
|
|
, const FPoint& termPos
|
2015-09-22 04:18:20 +02:00
|
|
|
, int wheel )
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
2018-12-03 03:22:36 +01:00
|
|
|
, p{pos}
|
|
|
|
, tp{termPos}
|
|
|
|
, w{wheel}
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-24 18:11:16 +01:00
|
|
|
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
2015-09-22 04:18:20 +02:00
|
|
|
, const FPoint& pos
|
|
|
|
, int wheel )
|
2018-12-03 03:22:36 +01:00
|
|
|
: FWheelEvent(ev_type, pos, FPoint(), wheel)
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWheelEvent::~FWheelEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
const FPoint& FWheelEvent::getPos() const
|
|
|
|
{ return p; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
const FPoint& FWheelEvent::getTermPos() const
|
|
|
|
{ return tp; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FWheelEvent::getX() const
|
|
|
|
{ return p.getX(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FWheelEvent::getY() const
|
|
|
|
{ return p.getY(); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
int FWheelEvent::getTermX() const
|
|
|
|
{ return tp.getX(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-25 23:53:48 +02:00
|
|
|
int FWheelEvent::getTermY() const
|
|
|
|
{ return tp.getY(); }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FWheelEvent::getWheel() const
|
|
|
|
{ return w; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FFocusEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FFocusEvent::FFocusEvent (fc::events ev_type) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FFocusEvent::~FFocusEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FFocusEvent::gotFocus() const
|
|
|
|
{
|
2017-09-17 21:32:46 +02:00
|
|
|
return ( type() == fc::FocusIn_Event );
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FFocusEvent::lostFocus() const
|
|
|
|
{
|
2017-09-17 21:32:46 +02:00
|
|
|
return ( type() == fc::FocusOut_Event );
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-01-17 02:57:08 +01:00
|
|
|
fc::FocusTypes FFocusEvent::getFocusType() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{ return focus_type; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-01-17 02:57:08 +01:00
|
|
|
void FFocusEvent::setFocusType(fc::FocusTypes ft)
|
2015-05-23 13:35:12 +02:00
|
|
|
{ focus_type = ft; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FFocusEvent::isAccepted() const
|
|
|
|
{ return accpt; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FFocusEvent::accept()
|
|
|
|
{ accpt = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FFocusEvent::ignore()
|
|
|
|
{ accpt = false; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FAccelEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
2018-12-03 03:22:36 +01:00
|
|
|
, focus_widget{focused}
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FAccelEvent::~FAccelEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void* FAccelEvent::focusedWidget() const
|
|
|
|
{ return focus_widget; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FAccelEvent::isAccepted() const
|
|
|
|
{ return accpt; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FAccelEvent::accept()
|
|
|
|
{ accpt = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FAccelEvent::ignore()
|
|
|
|
{ accpt = false; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FResizeEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FResizeEvent::FResizeEvent (fc::events ev_type) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FResizeEvent::~FResizeEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FResizeEvent::isAccepted() const
|
|
|
|
{ return accpt; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FResizeEvent::accept()
|
|
|
|
{ accpt = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FResizeEvent::ignore()
|
|
|
|
{ accpt = false; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FShowEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FShowEvent::FShowEvent (fc::events ev_type) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FShowEvent::~FShowEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FHideEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FHideEvent::FHideEvent (fc::events ev_type) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FHideEvent::~FHideEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FCloseEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FCloseEvent::FCloseEvent (fc::events ev_type) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCloseEvent::~FCloseEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FCloseEvent::isAccepted() const
|
|
|
|
{ return accpt; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FCloseEvent::accept()
|
|
|
|
{ accpt = true; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FCloseEvent::ignore()
|
|
|
|
{ accpt = false; }
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTimerEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor
|
2015-09-20 05:44:50 +02:00
|
|
|
: FEvent(ev_type)
|
2018-12-03 03:22:36 +01:00
|
|
|
, id{timer_id}
|
2015-09-20 05:44:50 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FTimerEvent::~FTimerEvent() // destructor
|
|
|
|
{ }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-12-24 18:11:16 +01:00
|
|
|
int FTimerEvent::getTimerId() const
|
2015-05-23 13:35:12 +02:00
|
|
|
{ return id; }
|
2018-09-20 23:59:01 +02:00
|
|
|
|
2018-12-24 18:11:16 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FUserEvent
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor
|
|
|
|
: FEvent(ev_type)
|
|
|
|
, uid{user_event_id}
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FUserEvent::~FUserEvent() // destructor
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FUserEvent::getUserId() const
|
|
|
|
{ return uid; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FUserEvent::data_ptr FUserEvent::getData() const
|
|
|
|
{ return data_pointer; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FUserEvent::setData (data_ptr data)
|
|
|
|
{ data_pointer = data; }
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|