finalcut/src/include/final/fevent.h

373 lines
9.7 KiB
C
Raw Normal View History

2017-11-04 07:03:53 +01:00
/***********************************************************************
* fevent.h - Base event class of widgets *
* *
* This file is part of the Final Cut widget toolkit *
* *
* 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/>. *
***********************************************************************/
/* Inheritance diagram
*
*
*
* FEvent
*
*
*
*
* FKeyEvent
*
*
*
* FMouseEvent
*
*
*
* FWheelEvent
*
*
*
* FFocusEvent
*
*
*
* FAccelEvent
*
*
*
* FResizeEvent
*
*
*
* FShowEvent
*
*
*
* FHideEvent
*
*
*
* FCloseEvent
*
*
*
* FTimerEvent
*
*/
2015-05-23 13:35:12 +02:00
#ifndef FEVENT_H
#define FEVENT_H
2015-05-23 13:35:12 +02:00
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include "final/fc.h"
#include "final/fpoint.h"
2018-12-27 00:14:46 +01:00
#include "final/ftypes.h"
2015-05-23 13:35:12 +02:00
namespace finalcut
{
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FEvent // event base class
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FEvent() = default;
explicit FEvent(fc::events);
fc::events type() const;
2015-05-23 13:35:12 +02:00
2017-09-11 03:06:02 +02:00
protected:
fc::events t{fc::None_Event};
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FKeyEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FKeyEvent : public FEvent // keyboard event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FKeyEvent() = default;
FKeyEvent (fc::events, FKey);
2017-09-11 03:06:02 +02:00
~FKeyEvent();
2018-11-21 20:07:08 +01:00
FKey key() const;
2017-09-11 03:06:02 +02:00
bool isAccepted() const;
void accept();
void ignore();
protected:
FKey k{0};
bool accpt{false};
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FMouseEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FMouseEvent : public FEvent // mouse event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FMouseEvent() = default;
FMouseEvent (fc::events, const FPoint&, const FPoint&, int);
FMouseEvent (fc::events, const FPoint&, int);
2017-09-11 03:06:02 +02:00
~FMouseEvent();
const FPoint& getPos() const;
const FPoint& getTermPos() const;
int getX() const;
int getY() const;
int getTermX() const;
int getTermY() const;
int getButton() const;
protected:
FPoint p;
FPoint tp;
int b;
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
2015-05-23 13:35:12 +02:00
//----------------------------------------------------------------------
// class FWheelEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FWheelEvent : public FEvent // wheel event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FWheelEvent() = default;
FWheelEvent (fc::events, const FPoint&, int);
FWheelEvent (fc::events, const FPoint&, const FPoint&, int);
2017-09-11 03:06:02 +02:00
~FWheelEvent();
const FPoint& getPos() const;
const FPoint& getTermPos() const;
int getX() const;
int getY() const;
int getTermX() const;
int getTermY() const;
int getWheel() const;
protected:
FPoint p;
FPoint tp;
int w;
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FFocusEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FFocusEvent : public FEvent // focus event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FFocusEvent() = default;
explicit FFocusEvent (fc::events);
2017-09-11 03:06:02 +02:00
~FFocusEvent();
bool gotFocus() const;
bool lostFocus() const;
fc::FocusTypes getFocusType() const;
void setFocusType(fc::FocusTypes);
bool isAccepted() const;
void accept();
void ignore();
protected:
bool accpt{true};
fc::FocusTypes focus_type{fc::FocusDefiniteWidget};
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FAccelEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FAccelEvent : public FEvent // focus event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FAccelEvent() = default;
FAccelEvent (fc::events, void*);
FAccelEvent (const FAccelEvent&) = delete;
2017-09-11 03:06:02 +02:00
~FAccelEvent();
FAccelEvent& operator = (const FAccelEvent&) = delete;
2017-09-11 03:06:02 +02:00
void* focusedWidget() const;
bool isAccepted() const;
void accept();
void ignore();
protected:
bool accpt{false};
2017-09-11 03:06:02 +02:00
void* focus_widget;
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FResizeEvent
//----------------------------------------------------------------------
2017-09-11 03:06:02 +02:00
class FResizeEvent : public FEvent // resize event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FResizeEvent() = default;
explicit FResizeEvent (fc::events);
2017-09-11 03:06:02 +02:00
~FResizeEvent();
2015-09-20 05:44:50 +02:00
2017-09-11 03:06:02 +02:00
bool isAccepted() const;
void accept();
void ignore();
2015-05-23 13:35:12 +02:00
2017-09-11 03:06:02 +02:00
protected:
bool accpt{false};
2015-05-23 13:35:12 +02:00
};
//----------------------------------------------------------------------
// class FShowEvent
//----------------------------------------------------------------------
2017-09-11 03:06:02 +02:00
class FShowEvent : public FEvent // show event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FShowEvent() = default;
explicit FShowEvent (fc::events);
2017-09-11 03:06:02 +02:00
~FShowEvent();
2015-05-23 13:35:12 +02:00
};
//----------------------------------------------------------------------
// class FHideEvent
//----------------------------------------------------------------------
2017-09-11 03:06:02 +02:00
class FHideEvent : public FEvent // hide event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FHideEvent() = default;
explicit FHideEvent (fc::events);
2017-09-11 03:06:02 +02:00
~FHideEvent();
2015-05-23 13:35:12 +02:00
};
//----------------------------------------------------------------------
// class FCloseEvent
//----------------------------------------------------------------------
2017-09-11 03:06:02 +02:00
class FCloseEvent : public FEvent // close event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FCloseEvent() = default;
explicit FCloseEvent(fc::events);
2017-09-11 03:06:02 +02:00
~FCloseEvent();
2015-09-20 05:44:50 +02:00
2017-09-11 03:06:02 +02:00
bool isAccepted() const;
void accept();
void ignore();
2015-05-23 13:35:12 +02:00
2017-09-11 03:06:02 +02:00
protected:
bool accpt{false};
2015-05-23 13:35:12 +02:00
};
//----------------------------------------------------------------------
// class FTimerEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
2017-09-11 03:06:02 +02:00
class FTimerEvent : public FEvent // timer event
2015-05-23 13:35:12 +02:00
{
2017-09-11 03:06:02 +02:00
public:
FTimerEvent() = default;
FTimerEvent (fc::events, int);
2017-09-11 03:06:02 +02:00
~FTimerEvent();
2015-09-20 05:44:50 +02:00
int getTimerId() const;
2015-05-23 13:35:12 +02:00
2017-09-11 03:06:02 +02:00
protected:
int id;
2015-05-23 13:35:12 +02:00
};
#pragma pack(pop)
//----------------------------------------------------------------------
// class FUserEvent
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FUserEvent : public FEvent // timer event
{
public:
FUserEvent() = default;
FUserEvent (fc::events, int);
~FUserEvent();
int getUserId() const;
2018-12-27 00:14:46 +01:00
FDataPtr getData() const;
void setData (FDataPtr);
protected:
int uid;
2018-12-27 00:14:46 +01:00
FDataPtr data_pointer{nullptr};
};
#pragma pack(pop)
} // namespace finalcut
#endif // FEVENT_H