00001
00002
00003
00004
00005
00006 #ifndef Impala_Application_SDash_MonitorSelector_h
00007 #define Impala_Application_SDash_MonitorSelector_h
00008
00009 #ifndef OglGui_Window_h
00010 #include "OglGui/Window.h"
00011 #endif
00012
00013 #ifndef Impala_Application_SDash_MonitorSelectorListener_h
00014 #include "Application/sdash/MonitorSelectorListener.h"
00015 #endif
00016
00017
00018 namespace Impala {
00019 namespace Application {
00020 namespace SDash {
00021
00022 class MonitorSelector : public OglGui::Window,
00023 public OglGui::WindowListener
00024 {
00025
00026 typedef OglGui::Window Window;
00027
00028 public:
00029 MonitorSelector(Window *parent, int w, int h, int nCameras) :
00030 Window(parent,0,0,w,h)
00031 {
00032 Init(w,h,nCameras);
00033 }
00034
00035 void SetMonitorSelectorListener(MonitorSelectorListener* listener,
00036 void* listenerData = 0)
00037 {
00038 mListener = listener;
00039 mListenerData = listenerData;
00040 }
00041
00042 void HideOnSelect(bool mode=true)
00043 {
00044 mHideOnSelect = mode;
00045 }
00046
00047 virtual void
00048 WindowMouseEvent(Window *src, int msg, int but, int state,
00049 int x, int y, void* userData )
00050 {
00051 if (msg == oglMouseDown && mListener != 0)
00052 mListener->MonitorSelectionEvent(this, userData, mListenerData);
00053 if (msg == oglMouseDown && mHideOnSelect)
00054 SetVisible(false);
00055 }
00056
00057 virtual void WindowDisplayEvent(Window *src, void* userData)
00058 {
00059 OGC myOGC;
00060 OGCSave(&myOGC);
00061
00062 int w = src->W();
00063 int h = src->H();
00064 SetSolidLineColor(oglWHITE);
00065 DrawRectangle(3, 8, w-6, h-12);
00066 glPointSize(3);
00067 DrawPoint(w-5,4);
00068 DrawPoint(w-10,4);
00069 DrawPoint(w-15,4);
00070
00071 OGCRestore(&myOGC);
00072 }
00073
00074
00075 private:
00076 void Init(int w, int h, int nCameras)
00077 {
00078 int camW = (w-(nCameras+1)*4)/nCameras;
00079
00080 for (int i=0; i<3; i++)
00081 {
00082 mCameraSquares[i] = new Window(this,4+i*(camW+4),4,camW,h-8);
00083 mCameraSquares[i]->SetDoStateFeedback(true);
00084 mCameraSquares[i]->SetBorderType(BEV_RAISED);
00085 mCameraSquares[i]->SetBackground(oglBLACK);
00086 mCameraSquares[i]->SetWindowListener(this, i);
00087 }
00088 mListener = 0;
00089 mHideOnSelect = true;
00090 }
00091
00092 MonitorSelectorListener* mListener;
00093 void* mListenerData;
00094
00095 Window* mCameraSquares[3];
00096
00097 bool mHideOnSelect;
00098 };
00099
00100 }
00101 }
00102 }
00103 #endif
00104