LightWrap++
AC++wrapperfortheLightWave3DSDK
colour_picker.h
Go to the documentation of this file.
1 #ifndef LWPP_COLOUR_PICKER_H
2 #define LWPP_COLOUR_PICKER_H
3 
4 #include <lwpp/message.h>
5 
6 namespace lwpp
7 {
8  class ColourPicker : protected GlobalBase<LWColorActivateFunc>
9  {
10  LWColorPickLocal local;
11  public:
12  bool Pick(std::string title, float &red, float &green, float &blue)
13  {
14  local.title = title.c_str();
15  local.data = 0;
16  local.hotFunc = 0;
17  local.red = red;
18  local.green = green;
19  local.blue = blue;
20  int result = (*globPtr)(LWPP_COLORPICK_VERSION, &local);
21  if (result == AFUNC_OK && local.result > 0)
22  {
23  red = local.red;
24  green = local.green;
25  blue = local.blue;
26  return true;
27  }
28  return false;
29  }
30  bool Pick(std::string title, int &red, int &green, int &blue)
31  {
32  float i = 1.0f / 255.0f;
33  float r = red * i;
34  float g = green * i;
35  float b = blue * i;
36  if (Pick(title, r,g,b))
37  {
38  red = r * 255.0f;
39  green = g * 255.0f;
40  blue = b * 255.0f;
41  return true;
42  }
43  return false;
44  }
45  bool Pick(std::string title, int rgb[3])
46  {
47  return Pick(title, rgb[0], rgb[1], rgb[2]);
48  }
49  };
50 
51 } // end namespace lwpp
52 
53 #endif // LWPP_COLOUR_PICKER_H