Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. #include "Controls/AttributeControl.h"
  2.  
  3. #include <NsCore/ReflectionImplement.h>
  4. #include <NsGui/ResourceKeyType.h>
  5. #include <NsGui/UIElementData.h>
  6. #include <NsGui/FrameworkPropertyMetadata.h>
  7.  
  8. using namespace Noesis;
  9. using namespace Frontier::UI::Controls;
  10.  
  11. const DependencyProperty* AttributeControl::ValueProperty;
  12.  
  13. float AttributeControl::GetValue() const
  14. {
  15.     return Noesis::ContentControl::GetValue<float>(ValueProperty);
  16. }
  17.  
  18. void AttributeControl::SetValue(float value)
  19. {
  20.     Noesis::ContentControl::SetValue<float>(ValueProperty, value);
  21. }
  22.  
  23. const DependencyProperty* AttributeControl::MaximumProperty;
  24.  
  25. float AttributeControl::GetMaximum() const
  26. {
  27.     return Noesis::ContentControl::GetValue<float>(MaximumProperty);
  28. }
  29.  
  30. void AttributeControl::SetMaximum(float maximum)
  31. {
  32.     Noesis::ContentControl::SetValue<float>(MaximumProperty, maximum);
  33. }
  34.  
  35. const DependencyProperty* AttributeControl::LabelProperty;
  36.  
  37. const char* AttributeControl::GetLabel() const
  38. {
  39.     return Noesis::ContentControl::GetValue<const char*>(LabelProperty);
  40. }
  41.  
  42. void AttributeControl::SetLabel(const char* label)
  43. {
  44.     Noesis::ContentControl::SetValue<const char*>(LabelProperty, label);
  45. }
  46.  
  47. const DependencyProperty* AttributeControl::IconProperty;
  48.  
  49. const Noesis::ImageSource* AttributeControl::GetIcon() const
  50. {
  51.     return Noesis::ContentControl::GetValue<ImageSource*>(IconProperty);
  52. }
  53.  
  54. void AttributeControl::SetIcon(Noesis::ImageSource* imageSource)
  55. {
  56.     Noesis::ContentControl::SetValue<ImageSource*>(IconProperty, imageSource);
  57. }
  58.  
  59. NS_IMPLEMENT_REFLECTION(AttributeControl)
  60. {
  61.     NsMeta<TypeId>("Frontier.UI.Controls.AttributeControl");
  62.    
  63.     const auto Type = TypeOf<SelfClass>();
  64.     const auto DefaultStyleKey = ResourceKeyType::Create(Type);
  65.    
  66.     auto Data = NsMeta<UIElementData>(Type);
  67.     Data->RegisterProperty<float>(ValueProperty, "Value", FrameworkPropertyMetadata::Create(100.0, FrameworkOptions_None));
  68.     Data->RegisterProperty<float>(MaximumProperty, "Maximum", FrameworkPropertyMetadata::Create(100.0, FrameworkOptions_None));
  69.     Data->RegisterProperty<const char*>(LabelProperty, "Label", FrameworkPropertyMetadata::Create(FrameworkOptions_None));
  70.     Data->RegisterProperty<ImageSource>(IconProperty, "Icon", FrameworkPropertyMetadata::Create(nullptr, FrameworkOptions_None));
  71.     Data->OverrideMetadata<Ptr<ResourceKeyType>>(FrameworkElement::DefaultStyleKeyProperty, "DefaultStyleKey", FrameworkPropertyMetadata::Create(DefaultStyleKey, FrameworkOptions_None));
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement