00001 #ifndef OglGui_ViewRotateControl_h
00002 #define OglGui_ViewRotateControl_h
00003
00004 #ifndef OglGui_CrossControl_h
00005 #include "OglGui/CrossControl.h"
00006 #endif
00007
00008 namespace OglGui
00009 {
00010
00011 class ViewRotateControl : public CrossControl
00012 {
00013 public:
00014
00015 ViewRotateControl(int x, int y, int w, int h, Window* targetWnd=0) :
00016 CrossControl(x, y, w, h, targetWnd, VIEWROTATE_FW,
00017 "Rotate View", true)
00018 {
00019 Init(w, h, targetWnd);
00020 }
00021
00022 ViewRotateControl(Window *parent, int w, int h, Window* targetWnd=0) :
00023 CrossControl(parent, w, h, targetWnd, VIEWROTATE_FW,
00024 "Rotate View", true)
00025 {
00026 Init(w, h, targetWnd);
00027 }
00028
00029 ViewRotateControl(Window *parent, int x, int y, int w, int h,
00030 Window* targetWnd=0) :
00031 CrossControl(parent,x,y,w,h, targetWnd, VIEWROTATE_FW,
00032 "Rotate View", true)
00033 {
00034 Init(w, h, targetWnd);
00035 }
00036
00037 enum {
00038 VIEWROTATE_FW,
00039 VIEWROTATE_BW,
00040 VIEWROTATE_LEFT,
00041 VIEWROTATE_RIGHT,
00042 VIEWROTATE_UP,
00043 VIEWROTATE_DOWN
00044 };
00045
00046
00047
00048 virtual void
00049 ButtonSelectionEvent(Button *src, void* userData)
00050 {
00051 if (!mTargetWnd ) return;
00052
00053 OGLWND* oglWnd = mTargetWnd->GetOGLWND();
00054 bool is2D = mTargetWnd->Is2d();
00055
00056 if (userData == (void*)VIEWROTATE_FW)
00057 mKeyFunc(oglWnd, is2D ? oglCTRL('r') : 'Z',
00058 is2D ? oglControl|oglShift : 0);
00059 if (userData == (void*)VIEWROTATE_BW)
00060 mKeyFunc(oglWnd, is2D ? oglCTRL('r') : 'z', is2D ? oglControl : 0);
00061 if (userData == (void*)VIEWROTATE_LEFT && !is2D)
00062 mKeyFunc(oglWnd, 'y', 0);
00063 if (userData == (void*)VIEWROTATE_RIGHT && !is2D)
00064 mKeyFunc(oglWnd, 'Y', 0);
00065 if (userData == (void*)VIEWROTATE_UP && !is2D)
00066 mKeyFunc(oglWnd, 'x', 0);
00067 if (userData == (void*)VIEWROTATE_DOWN && !is2D)
00068 mKeyFunc(oglWnd, 'X', 0);
00069 if (src==mResetButton)
00070 mKeyFunc(oglWnd, oglHOME, oglShift);
00071 }
00072
00073 virtual void SetTargetWindow(Window* targetWnd)
00074 {
00075 CrossControl::SetTargetWindow(targetWnd);
00076
00077 if (!mTargetWnd )
00078 return;
00079
00080 bool is2D = mTargetWnd->Is2d();
00081 mButtonCross->Btn(2)->SetVisible(!is2D);
00082 mButtonCross->Btn(3)->SetVisible(!is2D);
00083 mButtonCross->Btn(4)->SetVisible(!is2D);
00084 mButtonCross->Btn(5)->SetVisible(!is2D);
00085
00086 mKeyFunc = is2D ? viewSys.KeyFunc : view3DSys.KeyFunc;
00087 }
00088
00089 private:
00090 void (*mKeyFunc)(OGLWND *, int, int);
00091
00092 void Init(int w, int h, Window* targetWnd)
00093 {
00094 SetTargetWindow(targetWnd);
00095 mButtonCross->SetTexts("Z-", "Z+", "Y", "Y", "X", "X");
00096 }
00097 };
00098
00099 }
00100
00101 #endif