1 /* 2 * Copyright 2001 Werner Freytag - please read to the LICENSE file 3 * 4 * Copyright 2002-2015, Stephan Aßmus <superstippi@gmx.de> 5 * All rights reserved. 6 * 7 */ 8 9 #ifndef COLOR_PICKER_VIEW_H 10 #define COLOR_PICKER_VIEW_H 11 12 #include <String.h> 13 #include <View.h> 14 15 #include "SelectedColorMode.h" 16 17 #define MSG_RADIOBUTTON 'Rad0' 18 #define MSG_TEXTCONTROL 'Txt0' 19 #define MSG_HEXTEXTCONTROL 'HTxt' 20 #define MSG_UPDATE_COLOR_PICKER_VIEW 'UpCp' 21 22 class ColorField; 23 class ColorSlider; 24 class ColorPreview; 25 26 class BRadioButton; 27 class BTextControl; 28 29 class ColorPickerView : public BView { 30 public: 31 ColorPickerView(const char* name, 32 rgb_color color, 33 SelectedColorMode mode); 34 virtual ~ColorPickerView(); 35 36 // BView interface 37 virtual void AttachedToWindow(); 38 virtual void MessageReceived(BMessage *message); 39 40 // ColorPickerView 41 void SetColorMode(SelectedColorMode mode, 42 bool update = true); 43 void SetColor(rgb_color color); 44 rgb_color Color(); Mode()45 SelectedColorMode Mode() const 46 { return fSelectedColorMode; } 47 48 private: 49 int32 _NumForMode(SelectedColorMode mode) const; 50 51 void _UpdateColor(float value, float value1, 52 float value2); 53 void _UpdateTextControls(); 54 55 int _TextControlValue(int32 index); 56 bool _SetTextControlValue(int32 index, int value); 57 BString _HexTextControlString() const; 58 bool _SetHexTextControlString(const BString& text); 59 bool _SetText(BTextControl* control, 60 const BString& text); 61 62 63 private: 64 SelectedColorMode fSelectedColorMode; 65 66 float h, s, v, r, g, b; 67 float *p, *p1, *p2; 68 69 bool fRequiresUpdate; 70 71 ColorField* fColorField; 72 ColorSlider* fColorSlider; 73 ColorPreview* fColorPreview; 74 75 BRadioButton* fRadioButton[6]; 76 BTextControl* fTextControl[6]; 77 BTextControl* fHexTextControl; 78 }; 79 80 #endif // COLOR_PICKER_VIEW_H 81 82 83