00001
00002
00004
00005 #ifndef OglGui_ColorDialog_h
00006 #define OglGui_ColorDialog_h
00007
00008 #ifndef OglGui_ScrollWnd_h
00009 #include "OglGui/ScrollWnd.h"
00010 #endif
00011
00012 #include "OglGui/RgbSliderDialog.h"
00013 #include "OglGui/ColorsNamed.h"
00014
00015 namespace OglGui {
00016
00017 class ColorDialog : public Window,
00018 public ColorsNamedListener
00019 {
00020 public:
00021 const static int PREF_W = 600;
00022 const static int PREF_H = ColorsNamed::PREF_H+8;
00023
00024 ColorDialog(int x, int y, int w, int h, bool shaded=false) :
00025 Window(x,y,w,h)
00026 {
00027 Init(w,h,shaded);
00028 }
00029
00030 ColorDialog(Window* parent, int w, int h, bool shaded=false) :
00031 Window(parent,w,h)
00032 {
00033 Init(w,h,shaded);
00034 }
00035
00036 ColorDialog(Window* parent, int x, int y, int w, int h, bool shaded=false) :
00037 Window(parent,x,y,w,h)
00038 {
00039 Init(w,h,shaded);
00040 }
00041
00042 void Color(ULONG col) { mRgbSliderDialog->ColSlider()->Color(col); }
00043 ULONG Color() { return mRgbSliderDialog->ColSlider()->Color(); }
00044
00045 virtual void
00046 OnColorName(ColorsNamed *src,std::string colorName,ULONG color,
00047 int msg, void* userData)
00048 {
00049 int r, g, b;
00050 COLOR2RGB(color,r,g,b);
00051 mRgbSliderDialog->ColSlider()->RedBar() ->SetValue(r);
00052 mRgbSliderDialog->ColSlider()->GreenBar()->SetValue(g);
00053 mRgbSliderDialog->ColSlider()->BlueBar() ->SetValue(b);
00054 if (msg==oglMouseDblClick)
00055 OkBtn()->DoButtonSelectionEvent();
00056 }
00057
00058 RgbSliderDialog* RgbSliderDlg() { return mRgbSliderDialog; }
00059
00060 Button* OkBtn() { return mRgbSliderDialog->OkBtn(); }
00061 Button* CancelBtn() { return mRgbSliderDialog->CancelBtn(); }
00062 Window* ColorWnd() { return mRgbSliderDialog->ColSlider()->ColorWnd(); }
00063
00064 ColorsNamed* NamedColors() { return mColorsNamed; }
00065
00066 private:
00067 void Init(int w, int h, bool shaded)
00068 {
00069 SetBorderType(BEV_ETCHED);
00070 SetDimensions(PREF_W, PREF_H);
00071
00072 int rgbW = RgbSliderDialog::PREF_W;
00073 mRgbSliderDialog =
00074 new RgbSliderDialog(this,PREF_W-rgbW-4,4,rgbW,PREF_H-8,shaded);
00075 mRgbSliderDialog->ConnectTo(this,L2R|R2R|B2B|T2T);
00076
00077
00078 mColorsNamed =
00079 new ColorsNamed(this, 4, 4, PREF_W-rgbW-8, PREF_H-8,shaded);
00080 mColorsNamed->SetColorsNamedListener(this);
00081 mColorsNamed->ConnectTo(this);
00082
00083
00084
00085 SetAllowChildScaling(false);
00086 SetDimensions(w,h);
00087
00088 }
00089
00090 RgbSliderDialog* mRgbSliderDialog;
00091 ColorsNamed* mColorsNamed;
00092 };
00093 }
00094
00095 #endif