00001
00002
00004
00005 #ifndef OglGui_RgbSlider_h
00006 #define OglGui_RgbSlider_h
00007
00008 #ifndef OglGui_ValueScrollBar_h
00009 #include "OglGui/ValueScrollBar.h"
00010 #endif
00011
00012 namespace OglGui {
00013
00014 class RgbSlider : public Window,
00015 public ValueScrollBarListener
00016 {
00017 public:
00018 const static int PREF_W = 226;
00019 const static int PREF_H = 3*30+4*2;
00020
00021 RgbSlider(int x, int y, int w, int h, bool shaded=false) :
00022 Window(x,y,w,h)
00023 {
00024 Init(w,h,shaded);
00025 }
00026
00027 RgbSlider(Window* parent, int w, int h, bool shaded=false) :
00028 Window(parent,w,h)
00029 {
00030 Init(w,h,shaded);
00031 }
00032
00033 RgbSlider(Window* parent, int x, int y, int w, int h, bool shaded=false) :
00034 Window(parent,x,y,w,h)
00035 {
00036 Init(w,h,shaded);
00037 }
00038
00039 void Color(ULONG col)
00040 {
00041 int r,g,b;
00042 COLOR2RGB(col,r,g,b);
00043 mRedVSB ->SBar()->SetValue(r);
00044 mGreenVSB->SBar()->SetValue(g);
00045 mBlueVSB ->SBar()->SetValue(b);
00046 }
00047
00048 ULONG Color()
00049 {
00050 return mColorWnd->GetBorderBackground();
00051 }
00052
00053 void OnValueChanged(ValueScrollBar* vsb, int val, void* userData)
00054 {
00055 UCHAR red = mRedVSB ->SBar()->GetValue();
00056 UCHAR green = mGreenVSB->SBar()->GetValue();
00057 UCHAR blue = mBlueVSB ->SBar()->GetValue();
00058 ULONG col = ARGB2COLOR(255,red,green,blue);
00059 mColorWnd->SetBorderBackground(col);
00060 if (mShadedWnd)
00061 mShadedWnd->SetBorderBackground(col);
00062 }
00063
00064 ScrollBar* RedBar() { return mRedVSB ->SBar(); }
00065 ScrollBar* GreenBar() { return mGreenVSB->SBar(); }
00066 ScrollBar* BlueBar() { return mBlueVSB ->SBar(); }
00067 ValueScrollBar* RedVsbBar() { return mRedVSB; }
00068 ValueScrollBar* GreenVsbBar() { return mGreenVSB; }
00069 ValueScrollBar* BlueVsbBar() { return mBlueVSB; }
00070 Window* ColorWnd() { return mColorWnd; }
00071 Window* ShadedWnd() { return mShadedWnd; }
00072
00073 private:
00074 void Init(int w, int h, bool shaded)
00075 {
00076 SetBorderType(BEV_ETCHED);
00077 SetDimensions(PREF_W, PREF_H);
00078 int vsbW = W()-68;
00079 int vsbH = (H()-16)/3;
00080
00081 mRedVSB = new ValueScrollBar(this,4,H() -vsbH-4, vsbW, vsbH,0,255,0);
00082 mGreenVSB = new ValueScrollBar(this,4,H() -2*vsbH-8, vsbW, vsbH,0,255,0);
00083 mBlueVSB = new ValueScrollBar(this,4,H()-3*vsbH-12, vsbW, vsbH,0,255,0);
00084
00085 mRedVSB ->SBar() ->SetBorderBackground(oglLIGHTRED);
00086 mGreenVSB->SBar() ->SetBorderBackground(oglLIGHTGREEN);
00087 mBlueVSB ->SBar() ->SetBorderBackground(oglLIGHTBLUE);
00088
00089 mRedVSB ->ValText()->SetBorderBackground(oglRED);
00090 mGreenVSB->ValText()->SetBorderBackground(oglGREEN);
00091 mBlueVSB ->ValText()->SetBorderBackground(oglBLUE);
00092
00093 mRedVSB ->ValText()->SetForeground(oglWHITE);
00094 mGreenVSB->ValText()->SetForeground(oglWHITE);
00095 mBlueVSB ->ValText()->SetForeground(oglWHITE);
00096
00097 mRedVSB ->SetValueScrollBarListener(this);
00098 mGreenVSB->SetValueScrollBarListener(this);
00099 mBlueVSB ->SetValueScrollBarListener(this);
00100
00101 int colH = shaded ? H()/2 : H();
00102 mColorWnd = new Window(this,4+vsbW, 5, W()-vsbW-8, colH-8);
00103 mColorWnd->SetBorderType(BEV_ETCHED);
00104 mColorWnd->SetBorderBackground(oglBLACK);
00105
00106 mShadedWnd = 0;
00107 if (shaded)
00108 {
00109 mShadedWnd = new Window(this,4+vsbW, colH+4, W()-vsbW-8, colH-8);
00110 mShadedWnd->SetBorderType(BEV_ETCHED);
00111 mShadedWnd->SetBorderFillShaded(2);
00112 mShadedWnd->SetBorderBackground(oglBLACK);
00113 }
00114
00115 ScaleChildren();
00116 SetAllowChildScaling(false);
00117 SetDimensions(w,h);
00118 }
00119
00120 ValueScrollBar* mRedVSB;
00121 ValueScrollBar* mGreenVSB;
00122 ValueScrollBar* mBlueVSB;
00123 Window* mColorWnd;
00124 Window* mShadedWnd;
00125 };
00126 }
00127
00128 #endif