finalcut/src/fevent.cpp

376 lines
12 KiB
C++
Raw Normal View History

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>
#include "final/fevent.h"
2015-05-23 13:35:12 +02:00
namespace finalcut
{
2015-05-23 13:35:12 +02:00
2015-09-22 04:18:20 +02:00
//----------------------------------------------------------------------
// class FEvent
//----------------------------------------------------------------------
FEvent::FEvent (fc::events ev_type) // constructor
: t{ev_type}
2015-09-22 04:18:20 +02: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
//----------------------------------------------------------------------
FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor
2015-09-20 05:44:50 +02:00
: FEvent(ev_type)
, 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
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
2015-09-22 04:18:20 +02:00
, const FPoint& pos
, const FPoint& termPos
2015-09-22 04:18:20 +02:00
, int button )
2015-09-20 05:44:50 +02:00
: FEvent(ev_type)
, p{pos}
, tp{termPos}
, b{button}
2015-09-20 05:44:50 +02:00
{ }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
2015-09-22 04:18:20 +02:00
, const FPoint& pos
, int button )
: 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; }
//----------------------------------------------------------------------
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(); }
//----------------------------------------------------------------------
int FMouseEvent::getTermX() const
{ return tp.getX(); }
2015-05-23 13:35:12 +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
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
2015-09-22 04:18:20 +02:00
, const FPoint& pos
, const FPoint& termPos
2015-09-22 04:18:20 +02:00
, int wheel )
2015-09-20 05:44:50 +02:00
: FEvent(ev_type)
, p{pos}
, tp{termPos}
, w{wheel}
2015-09-20 05:44:50 +02:00
{ }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
2015-09-22 04:18:20 +02:00
, const FPoint& pos
, int wheel )
: 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; }
//----------------------------------------------------------------------
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(); }
//----------------------------------------------------------------------
int FWheelEvent::getTermX() const
{ return tp.getX(); }
2015-05-23 13:35:12 +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
//----------------------------------------------------------------------
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
{
return ( type() == fc::FocusIn_Event );
2015-05-23 13:35:12 +02:00
}
//----------------------------------------------------------------------
bool FFocusEvent::lostFocus() const
{
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
//----------------------------------------------------------------------
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor
2015-09-20 05:44:50 +02:00
: FEvent(ev_type)
, 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
//----------------------------------------------------------------------
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
//----------------------------------------------------------------------
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
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FHideEvent
//----------------------------------------------------------------------
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
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FCloseEvent
//----------------------------------------------------------------------
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
//----------------------------------------------------------------------
FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor
2015-09-20 05:44:50 +02:00
: FEvent(ev_type)
, id{timer_id}
2015-09-20 05:44:50 +02:00
{ }
//----------------------------------------------------------------------
FTimerEvent::~FTimerEvent() // destructor
{ }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
int FTimerEvent::getTimerId() const
2015-05-23 13:35:12 +02:00
{ return id; }
//----------------------------------------------------------------------
// 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; }
//----------------------------------------------------------------------
2018-12-27 00:14:46 +01:00
FDataPtr FUserEvent::getData() const
{ return data_pointer; }
//----------------------------------------------------------------------
2018-12-27 00:14:46 +01:00
void FUserEvent::setData (FDataPtr data)
{ data_pointer = data; }
} // namespace finalcut