1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
|
/***********************************************************************
* fevent.cpp - Base event class of widgets *
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2014-2022 Markus Gans *
* *
* 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. *
* *
* 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/>. *
***********************************************************************/
#include <cstdio>
#include "final/fevent.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FEvent
//----------------------------------------------------------------------
FEvent::FEvent (Event ev_type) // constructor
: t{ev_type}
{ }
//----------------------------------------------------------------------
auto FEvent::getType() const -> Event
{ return t; }
//----------------------------------------------------------------------
auto FEvent::isQueued() const -> bool
{ return queued; }
//----------------------------------------------------------------------
auto FEvent::wasSent() const -> bool
{ return send; }
//----------------------------------------------------------------------
// class FKeyEvent
//----------------------------------------------------------------------
FKeyEvent::FKeyEvent (Event ev_type, FKey key_num) // constructor
: FEvent{ev_type}
, k{key_num}
{ }
//----------------------------------------------------------------------
auto FKeyEvent::key() const -> FKey
{ return k; }
//----------------------------------------------------------------------
auto FKeyEvent::isAccepted() const -> bool
{ return accpt; }
//----------------------------------------------------------------------
void FKeyEvent::accept()
{ accpt = true; }
//----------------------------------------------------------------------
void FKeyEvent::ignore()
{ accpt = false; }
//----------------------------------------------------------------------
// class FMouseEvent
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( Event ev_type // constructor
, const FPoint& pos
, const FPoint& termPos
, MouseButton button )
: FEvent{ev_type}
, p{pos}
, tp{termPos}
, b{button}
{ }
//----------------------------------------------------------------------
FMouseEvent::FMouseEvent ( Event ev_type // constructor
, const FPoint& pos
, MouseButton button )
: FMouseEvent{ev_type, pos, FPoint{}, button}
{ }
//----------------------------------------------------------------------
auto FMouseEvent::getPos() const & -> const FPoint&
{ return p; }
//----------------------------------------------------------------------
auto FMouseEvent::getTermPos() const & -> const FPoint&
{ return tp; }
//----------------------------------------------------------------------
auto FMouseEvent::getX() const -> int
{ return p.getX(); }
//----------------------------------------------------------------------
auto FMouseEvent::getY() const -> int
{ return p.getY(); }
//----------------------------------------------------------------------
auto FMouseEvent::getTermX() const -> int
{ return tp.getX(); }
//----------------------------------------------------------------------
auto FMouseEvent::getTermY() const -> int
{ return tp.getY(); }
//----------------------------------------------------------------------
auto FMouseEvent::getButton() const -> MouseButton
{ return b; }
//----------------------------------------------------------------------
void FMouseEvent::setPos (const FPoint& pos)
{ p = pos; }
//----------------------------------------------------------------------
void FMouseEvent::setTermPos (const FPoint& termPos)
{ tp = termPos; }
//----------------------------------------------------------------------
// class FWheelEvent
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( Event ev_type // constructor
, const FPoint& pos
, const FPoint& termPos
, MouseWheel wheel )
: FEvent{ev_type}
, p{pos}
, tp{termPos}
, w{wheel}
{ }
//----------------------------------------------------------------------
FWheelEvent::FWheelEvent ( Event ev_type // constructor
, const FPoint& pos
, MouseWheel wheel )
: FWheelEvent{ev_type, pos, FPoint{}, wheel}
{ }
//----------------------------------------------------------------------
auto FWheelEvent::getPos() const & -> const FPoint&
{ return p; }
//----------------------------------------------------------------------
auto FWheelEvent::getTermPos() const & -> const FPoint&
{ return tp; }
//----------------------------------------------------------------------
auto FWheelEvent::getX() const -> int
{ return p.getX(); }
//----------------------------------------------------------------------
auto FWheelEvent::getY() const -> int
{ return p.getY(); }
//----------------------------------------------------------------------
auto FWheelEvent::getTermX() const -> int
{ return tp.getX(); }
//----------------------------------------------------------------------
auto FWheelEvent::getTermY() const -> int
{ return tp.getY(); }
//----------------------------------------------------------------------
auto FWheelEvent::getWheel() const -> MouseWheel
{ return w; }
//----------------------------------------------------------------------
// class FFocusEvent
//----------------------------------------------------------------------
FFocusEvent::FFocusEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
auto FFocusEvent::gotFocus() const -> bool
{
return getType() == Event::FocusIn;
}
//----------------------------------------------------------------------
auto FFocusEvent::lostFocus() const -> bool
{
return getType() == Event::FocusOut;
}
//----------------------------------------------------------------------
auto FFocusEvent::getFocusType() const -> FocusTypes
{ return focus_type; }
//----------------------------------------------------------------------
void FFocusEvent::setFocusType (FocusTypes ft)
{ focus_type = ft; }
//----------------------------------------------------------------------
auto FFocusEvent::isAccepted() const -> bool
{ return accpt; }
//----------------------------------------------------------------------
void FFocusEvent::accept()
{ accpt = true; }
//----------------------------------------------------------------------
void FFocusEvent::ignore()
{ accpt = false; }
//----------------------------------------------------------------------
// class FAccelEvent
//----------------------------------------------------------------------
FAccelEvent::FAccelEvent (Event ev_type, FWidget* focused) // constructor
: FEvent{ev_type}
, focus_widget{focused}
{ }
//----------------------------------------------------------------------
auto FAccelEvent::focusedWidget() const -> FWidget*
{ return focus_widget; }
//----------------------------------------------------------------------
auto FAccelEvent::isAccepted() const -> bool
{ return accpt; }
//----------------------------------------------------------------------
void FAccelEvent::accept()
{ accpt = true; }
//----------------------------------------------------------------------
void FAccelEvent::ignore()
{ accpt = false; }
//----------------------------------------------------------------------
// class FResizeEvent
//----------------------------------------------------------------------
FResizeEvent::FResizeEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
auto FResizeEvent::isAccepted() const -> bool
{ return accpt; }
//----------------------------------------------------------------------
void FResizeEvent::accept()
{ accpt = true; }
//----------------------------------------------------------------------
void FResizeEvent::ignore()
{ accpt = false; }
//----------------------------------------------------------------------
// class FShowEvent
//----------------------------------------------------------------------
FShowEvent::FShowEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
// class FHideEvent
//----------------------------------------------------------------------
FHideEvent::FHideEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
// class FCloseEvent
//----------------------------------------------------------------------
FCloseEvent::FCloseEvent (Event ev_type) // constructor
: FEvent{ev_type}
{ }
//----------------------------------------------------------------------
auto FCloseEvent::isAccepted() const -> bool
{ return accpt; }
//----------------------------------------------------------------------
void FCloseEvent::accept()
{ accpt = true; }
//----------------------------------------------------------------------
void FCloseEvent::ignore()
{ accpt = false; }
//----------------------------------------------------------------------
// class FTimerEvent
//----------------------------------------------------------------------
FTimerEvent::FTimerEvent (Event ev_type, int timer_id) // constructor
: FEvent{ev_type}
, id{timer_id}
{ }
//----------------------------------------------------------------------
auto FTimerEvent::getTimerId() const -> int
{ return id; }
//----------------------------------------------------------------------
// class FUserEvent
//----------------------------------------------------------------------
FUserEvent::FUserEvent (Event ev_type, int user_event_id) // constructor
: FEvent{ev_type}
, uid{user_event_id}
{ }
//----------------------------------------------------------------------
auto FUserEvent::getUserId() const -> int
{ return uid; }
} // namespace finalcut
|