control.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007-2008 Martin Pieuchot 
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
00017  * USA
00018  */
00019 
00020 #ifndef _WX_OGRE_CONTROL_H_
00021 #define _WX_OGRE_CONTROL_H_
00022 
00023 #include <Ogre.h>
00024 #include <wx/wx.h>
00025 
00035 class wxOgreControl : public wxControl
00036 {
00037     DECLARE_DYNAMIC_CLASS(wxOgreControl)
00038     DECLARE_EVENT_TABLE()
00039 
00040 public:
00041 
00043     wxOgreControl(); 
00044 
00046     wxOgreControl(wxWindow* parent, wxWindowID id = wxID_ANY,
00047                         const wxPoint& pos = wxDefaultPosition,
00048                         const wxSize& size = wxDefaultSize,
00049                         long style = wxSUNKEN_BORDER | wxTRANSPARENT_WINDOW,
00050                         const wxValidator& val = wxDefaultValidator,
00051                         const wxString& name = wxT("OgreControl"));
00052 
00062     virtual ~wxOgreControl();
00063 
00065     virtual bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
00066                         const wxPoint& pos = wxDefaultPosition,
00067                         const wxSize& size = wxDefaultSize,
00068                         long style = wxSUNKEN_BORDER | wxTRANSPARENT_WINDOW,
00069                         const wxValidator& val = wxDefaultValidator,
00070                         const wxString& name = wxT("OgreControl"));
00071 
00073     virtual bool Destroy();
00074 
00076     virtual void Update();
00077 
00082     virtual wxSize DoGetBestSize() const { return wxSize(320, 240); }
00083 
00084 
00089     virtual Ogre::SceneManager* CreateSceneManager(const Ogre::String& tn,
00090                                                    const Ogre::String& name="");
00091 
00096     virtual Ogre::SceneManager* CreateSceneManager(Ogre::SceneTypeMask tm,
00097                                                    const Ogre::String& name="");
00098 
00107     virtual void SetSceneManager(Ogre::SceneManager* sm);
00108 
00116     virtual void SetCamera(Ogre::Camera* cam);
00117 
00125     virtual void RotateCamera(float relX, float relY, float relZ);
00126 
00132     virtual void TranslateCamera(float x, float y, float z);
00133 
00138     virtual void SetPolygonMode(const Ogre::PolygonMode& pm);
00139 
00152     virtual void ProcessSelection(const wxPoint& pt);
00153 
00155     Ogre::Camera* GetCamera() const { return m_cam; }
00156 
00158     Ogre::RenderWindow* GetRenderWindow() const { return m_rwin; } 
00159 
00161     Ogre::Viewport* GetViewport() const { return m_vp; }
00162 
00167     void AddViewport(Ogre::Camera* cam, int ZOrder=0, float left=0.0f,
00168                      float top=0.0f, float  width=1.0f, float height=1.0f);
00169 
00174     void DestroyRenderWindow();
00175 
00176 protected:
00177 
00178     virtual void OnSize(wxSizeEvent& event);
00179     virtual void OnPaint(wxPaintEvent& event);
00180     virtual void OnMouseMove(wxMouseEvent& event);
00181     virtual void OnEraseBackground(wxEraseEvent& event);
00182 
00183     Ogre::SceneManager* m_sm;
00184     Ogre::Camera*       m_cam;
00185 
00186 private:
00187 
00189     virtual void Init();
00190 
00195     Ogre::RenderWindow* CreateRenderWindow(const Ogre::String& name);
00196 
00207     void GetParentWindowHandle(Ogre::NameValuePairList& pl);
00208 
00209 
00210     Ogre::Root*         m_root;
00211     Ogre::RenderWindow* m_rwin;
00212     Ogre::Viewport*     m_vp;
00213 
00214 
00216     long m_x;
00218     long m_y;
00219 
00221     static unsigned int m_instances;
00222 };
00223 
00224 #endif