finalcut/src/include/final/fevent.h

351 lines
9.1 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"
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;
2017-09-11 03:06:02 +02:00
explicit FEvent(int);
virtual ~FEvent();
int type() const;
2015-05-23 13:35:12 +02:00
2017-09-11 03:06:02 +02:00
protected:
int 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;
2018-11-21 20:07:08 +01:00
FKeyEvent (int, 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;
2017-09-11 03:06:02 +02:00
FMouseEvent (int, const FPoint&, const FPoint&, int);
FMouseEvent (int, 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;
2017-09-11 03:06:02 +02:00
FWheelEvent (int, const FPoint&, int);
FWheelEvent (int, const FPoint&, const FPoint&, int);
~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;
2017-09-11 03:06:02 +02:00
explicit FFocusEvent (int);
~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;
2017-09-11 03:06:02 +02:00
FAccelEvent (int, 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;
2017-09-11 03:06:02 +02:00
explicit FResizeEvent (int);
~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;
2017-09-11 03:06:02 +02:00
explicit FShowEvent (int);
~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;
2017-09-11 03:06:02 +02:00
explicit FHideEvent (int);
~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;
2017-09-11 03:06:02 +02:00
explicit FCloseEvent(int);
~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;
2017-09-11 03:06:02 +02:00
FTimerEvent(int, int);
~FTimerEvent();
2015-09-20 05:44:50 +02:00
2017-09-11 03:06:02 +02:00
int timerId() 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)
} // namespace finalcut
#endif // FEVENT_H