Merge "use modern construct '= default' for special functions." into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.cpp
old mode 100755 (executable)
new mode 100644 (file)
index aa5ba9a..fe6bfcf
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 namespace Dali
 {
-
-namespace
+KeyEvent::KeyEvent()
+: BaseHandle()
 {
-const unsigned int MODIFIER_SHIFT = 0x1;
-const unsigned int MODIFIER_CTRL  = 0x2;
-const unsigned int MODIFIER_ALT   = 0x4;
-const int KEY_INVALID_CODE = -1;
 }
 
-KeyEvent::KeyEvent()
-: keyPressedName(""),
-  keyPressed(""),
-  keyCode(KEY_INVALID_CODE),
-  keyModifier(0),
-  time(0),
-  state(KeyEvent::Down)
+KeyEvent::KeyEvent(const KeyEvent& rhs) = default;
+
+KeyEvent::KeyEvent(KeyEvent&& rhs) = default;
+
+KeyEvent::~KeyEvent() = default;
+
+KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) = default;
+
+KeyEvent& KeyEvent::operator=(KeyEvent&& rhs) = default;
+
+bool KeyEvent::IsShiftModifier() const
 {
-  new Internal::KeyEventImpl( this );
+  return GetImplementation(*this).IsShiftModifier();
 }
 
-KeyEvent::KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier,unsigned long timeStamp, const State& keyState)
-: keyPressedName(keyName),
-  keyPressed(keyString),
-  keyCode(keyCode),
-  keyModifier(keyModifier),
-  time(timeStamp),
-  state(keyState)
+bool KeyEvent::IsCtrlModifier() const
 {
-  new Internal::KeyEventImpl( this );
+  return GetImplementation(*this).IsCtrlModifier();
 }
 
-KeyEvent::KeyEvent( const KeyEvent& rhs )
-: keyPressedName( rhs.keyPressedName ),
-  keyPressed( rhs.keyPressed ),
-  keyCode( rhs.keyCode ),
-  keyModifier( rhs.keyModifier ),
-  time( rhs.time ),
-  state( rhs.state )
+bool KeyEvent::IsAltModifier() const
 {
-  Internal::KeyEventImpl* impl = new Internal::KeyEventImpl( this );
-  *impl = *GetImplementation( &rhs );
+  return GetImplementation(*this).IsAltModifier();
 }
 
-KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
+const std::string& KeyEvent::GetCompose() const
 {
-  if( this != &rhs )
-  {
-    keyPressedName = rhs.keyPressedName;
-    keyPressed = rhs.keyPressed;
-    keyCode = rhs.keyCode;
-    keyModifier = rhs.keyModifier;
-    time = rhs.time;
-    state = rhs.state;
-
-    *GetImplementation( this ) = *GetImplementation( &rhs );
-  }
-
-  return *this;
+  return GetImplementation(*this).GetCompose();
 }
 
-KeyEvent::~KeyEvent()
+const std::string& KeyEvent::GetDeviceName() const
 {
-  delete GetImplementation( this );
+  return GetImplementation(*this).GetDeviceName();
 }
 
-bool KeyEvent::IsShiftModifier() const
+Device::Class::Type KeyEvent::GetDeviceClass() const
 {
-  if ((MODIFIER_SHIFT & keyModifier) == MODIFIER_SHIFT)
-  {
-    return true;
-  }
-
-  return false;
+  return GetImplementation(*this).GetDeviceClass();
 }
 
-bool KeyEvent::IsCtrlModifier() const
+Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
 {
-  if ((MODIFIER_CTRL & keyModifier) == MODIFIER_CTRL)
-  {
-    return true;
-  }
+  return GetImplementation(*this).GetDeviceSubclass();
+}
 
-  return false;
+const std::string& KeyEvent::GetKeyName() const
+{
+  return GetImplementation(*this).GetKeyName();
 }
 
-bool KeyEvent::IsAltModifier() const
+const std::string& KeyEvent::GetKeyString() const
 {
-  if ((MODIFIER_ALT & keyModifier) == MODIFIER_ALT)
-  {
-    return true;
-  }
+  return GetImplementation(*this).GetKeyString();
+}
 
-  return false;
+const std::string& KeyEvent::GetLogicalKey() const
+{
+  return GetImplementation(*this).GetLogicalKey();
 }
 
-std::string KeyEvent::GetCompose() const
+int32_t KeyEvent::GetKeyCode() const
 {
-  return GetImplementation( this )->GetCompose();
+  return GetImplementation(*this).GetKeyCode();
 }
 
-std::string KeyEvent::GetDeviceName() const
+int32_t KeyEvent::GetKeyModifier() const
 {
-  return GetImplementation( this )->GetDeviceName();
+  return GetImplementation(*this).GetKeyModifier();
 }
 
-Device::Class::Type KeyEvent::GetDeviceClass() const
+unsigned long KeyEvent::GetTime() const
 {
-  return GetImplementation( this )->GetDeviceClass();
+  return GetImplementation(*this).GetTime();
 }
 
-Device::Subclass::Type KeyEvent::GetDeviceSubclass() const
+KeyEvent::State KeyEvent::GetState() const
 {
-  return GetImplementation( this )->GetDeviceSubclass();
+  return GetImplementation(*this).GetState();
 }
 
+KeyEvent::KeyEvent(Internal::KeyEvent* internal)
+: BaseHandle(internal)
+{
+}
 
 } // namespace Dali