00001
00002 #ifndef Impala_Visualization_PunsOnlyControl_h
00003 #define Impala_Visualization_PunsOnlyControl_h
00004
00005 #include "Visualization/PunsOnlyControlListener.h"
00006
00007 #ifndef OglGui_CheckBox_h
00008 #include "OglGui/Checkbox.h"
00009 #endif
00010
00011 namespace Impala {
00012 namespace Visualization {
00013
00014 class PunsOnlyControl : public OglGui::Window,
00015 public OglGui::CheckBoxListener
00016 {
00017 public:
00018 typedef OglGui::Window Window;
00019 typedef OglGui::CheckBox CheckBox;
00020
00021 PunsOnlyControl(Window* parent, int w, int h, int bits, int margin=0) :
00022 Window(parent, w, h)
00023 {
00024 Init(w,h,bits,margin);
00025 }
00026
00027 void SetListener(PunsOnlyControlListener* l, void* lData=0)
00028 {
00029 mListener = l;
00030 mListenerData = lData;
00031 }
00032
00033 virtual void
00034 CheckBoxEvent(CheckBox *src, bool checked, void* userData)
00035 {
00036 int uData = (long long) userData;
00037 if (checked && (uData > 0 && uData < 5))
00038 {
00039 if (mPositiveCheckBox) mPositiveCheckBox->SetSelected(uData==1);
00040 if (mUnknownCheckBox) mUnknownCheckBox->SetSelected(uData==2);
00041 if (mNegativeCheckBox) mNegativeCheckBox->SetSelected(uData==3);
00042 if (mSkipCheckBox) mSkipCheckBox->SetSelected(uData==4);
00043 }
00044 if (mListener)
00045 mListener->PunsOnlyChanged(this, mListenerData);
00046 }
00047
00048 CheckBox* PositiveCheckBox() { return mPositiveCheckBox; }
00049 CheckBox* UnknownCheckBox() { return mUnknownCheckBox; }
00050 CheckBox* NegativeCheckBox() { return mNegativeCheckBox; }
00051 CheckBox* SkipCheckBox() { return mSkipCheckBox; }
00052
00053 private:
00054 void Init(int w, int h, int bits, int margin)
00055 {
00056 int x = margin;
00057 mListener = 0;
00058
00059 mPositiveCheckBox = 0;
00060 mUnknownCheckBox = 0;
00061 mNegativeCheckBox = 0;
00062 mSkipCheckBox = 0;
00063
00064 if (bits & 1)
00065 {
00066 mPositiveCheckBox = new CheckBox(this,x,margin,110,h-2*margin,
00067 "Only Positive", false, 1);
00068 mPositiveCheckBox->SetCheckBoxListener(this,1);
00069 x += 112;
00070 }
00071 if (bits & 2)
00072 {
00073 mUnknownCheckBox = new CheckBox(this, x, margin, 110,h-2*margin,
00074 "Only Unknown", false, 1);
00075 mUnknownCheckBox->SetCheckBoxListener(this,2);
00076 x += 112;
00077 }
00078 if (bits & 4)
00079 {
00080 mNegativeCheckBox = new CheckBox(this, x, margin, 110,h-2*margin,
00081 "Only Negative", false, 1);
00082 mNegativeCheckBox->SetCheckBoxListener(this,3);
00083 x += 112;
00084 }
00085 if (bits & 8)
00086 {
00087 mSkipCheckBox = new CheckBox(this, x, margin, 110,h-2*margin,
00088 "Only Skip", false, 1);
00089 mSkipCheckBox->SetCheckBoxListener(this,4);
00090 x += 112;
00091 }
00092 x += margin;
00093
00094 SetDimensions(x,h);
00095 ScaleChildren();
00096 SetAllowChildScaling(false);
00097 SetDimensions(w,h);
00098 }
00099
00100 PunsOnlyControlListener* mListener;
00101 void* mListenerData;
00102
00103 CheckBox* mPositiveCheckBox;
00104 CheckBox* mUnknownCheckBox;
00105 CheckBox* mNegativeCheckBox;
00106 CheckBox* mSkipCheckBox;
00107 };
00108
00109 }
00110 }
00111
00112 #endif