finalcut/src/fevent.cpp

352 lines
11 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(int ev_type) // constructor
: t{ev_type}
2015-09-22 04:18:20 +02:00
{ }
//----------------------------------------------------------------------
FEvent::~FEvent() // destructor
{ }
//----------------------------------------------------------------------
int FEvent::type() const
{ return t; }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FKeyEvent
//----------------------------------------------------------------------
2018-11-21 20:07:08 +01:00
FKeyEvent::FKeyEvent (int 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
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FMouseEvent::FMouseEvent ( int ev_type // constructor
, 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
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FMouseEvent::FMouseEvent ( int ev_type // constructor
, 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
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FWheelEvent::FWheelEvent ( int ev_type // constructor
, 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
//----------------------------------------------------------------------
2015-09-22 04:18:20 +02:00
FWheelEvent::FWheelEvent ( int ev_type // constructor
, 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
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FFocusEvent::FFocusEvent (int ev_type) // constructor
: 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
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FAccelEvent::FAccelEvent(int ev_type, void* focused) // constructor
: 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
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FResizeEvent::FResizeEvent(int ev_type) // constructor
: 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
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FShowEvent::FShowEvent(int ev_type) // constructor
: FEvent(ev_type)
{ }
//----------------------------------------------------------------------
FShowEvent::~FShowEvent() // destructor
{ }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FHideEvent
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FHideEvent::FHideEvent(int ev_type) // constructor
: FEvent(ev_type)
{ }
//----------------------------------------------------------------------
FHideEvent::~FHideEvent() // destructor
{ }
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FCloseEvent
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FCloseEvent::FCloseEvent(int ev_type) // constructor
: 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
//----------------------------------------------------------------------
2015-09-20 05:44:50 +02:00
FTimerEvent::FTimerEvent(int ev_type, int timer_id) // constructor
: 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::timerId() const
{ return id; }
} // namespace finalcut