You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include <openvibe/ov_all.h>
  3. #include <gtk/gtk.h>
  4. #include <sstream>
  5. //---------------------------------------------------------------------------------------------------
  6. /// <summary> Initializes the color of the GDK. with old compiler as vs2013 we can't initialize structure easily.....</summary>
  7. /// <param name="pixel"> For allocated colors, the pixel value used to draw this color on the screen.Not used anymore.</param>
  8. /// <param name="r"> The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensity.</param>
  9. /// <param name="g"> The green component of the color.</param>
  10. /// <param name="b"> The blue component of the color.</param>
  11. /// <returns> The initialized color (</returns>
  12. inline GdkColor InitGDKColor(const guint32 pixel = 0, const guint16 r = 0, const guint16 g = 0, const guint16 b = 0)
  13. {
  14. GdkColor c;
  15. c.pixel = pixel;
  16. c.red = r;
  17. c.green = g;
  18. c.blue = b;
  19. return c;
  20. }
  21. //---------------------------------------------------------------------------------------------------
  22. //---------------------------------------------------------------------------------------------------
  23. class CGdkcolorAutoCast
  24. {
  25. public:
  26. CGdkcolorAutoCast(const OpenViBE::Kernel::IBox& box, OpenViBE::Kernel::IConfigurationManager& configManager, const size_t index)
  27. : m_configManager(configManager)
  28. {
  29. box.getSettingValue(index, m_settingValue);
  30. m_settingValue = m_configManager.expand(m_settingValue);
  31. }
  32. operator GdkColor() const
  33. {
  34. std::stringstream ss(m_settingValue.toASCIIString());
  35. int r = 0, g = 0, b = 0;
  36. char c;
  37. ss >> r >> c >> g >> c >> b;
  38. return InitGDKColor(0, guint16(r * 655.35), guint16(g * 655.35), guint16(b * 655.35));
  39. }
  40. protected:
  41. OpenViBE::Kernel::IConfigurationManager& m_configManager;
  42. OpenViBE::CString m_settingValue;
  43. };
  44. //---------------------------------------------------------------------------------------------------