Cafu Engine
RenderWindow.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_GUIEDITOR_RENDER_WINDOW_HPP_INCLUDED
8 #define CAFU_GUIEDITOR_RENDER_WINDOW_HPP_INCLUDED
9 
10 #include "ObserverPattern.hpp"
11 #include "Math3D/Vector2.hpp"
12 #include "wx/glcanvas.h"
13 
14 
15 namespace GuiEditor
16 {
17  class ChildFrameT;
18  class GuiDocumentT;
19 
20  class RenderWindowT : public wxGLCanvas, public ObserverT
21  {
22  public:
23 
24  RenderWindowT(ChildFrameT* Parent);
25 
26  // ObserverT implementation.
30  void NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> >& Windows, WindowModDetailE Detail);
31  void Notify_Changed(SubjectT* Subject, const cf::TypeSys::VarBaseT& Var);
32  void NotifySubjectDies(SubjectT* dyingSubject);
33 
34  Vector2fT ClientToGui(int x, int y) const;
35  wxPoint GuiToClient(const Vector2fT& Pos) const;
36 
37  void ZoomIn();
38  void ZoomOut();
39  void ZoomFit();
40  void ZoomSet(float ZoomFactor);
41 
42 
43  private:
44 
45  GuiDocumentT* m_GuiDocument;
46  ChildFrameT* m_Parent;
47  unsigned long m_TimeLastFrame;
48  float m_Zoom;
49 
50  float m_OffsetX;
51  float m_OffsetY;
52 
53  void UpdateScrollbars(); ///< Helper to calculate scroll ranges based on client size and zoom factor.
54  void CalcViewOffsets(); ///< Helper to calculate the view offsets based on client size and zoom factor.
55  void ScrollWindow(int AmountX, int AmountY); ///< Helper to scroll the window.
56  void CenterView(); ///< Helper to center the GUI in the render window.
57 
58  void OnPaint (wxPaintEvent& PE);
59  void OnMouseWheel(wxMouseEvent& ME);
60  void OnSize (wxSizeEvent& SE);
61  void OnMouseMove (wxMouseEvent& ME);
62  void OnLMouseDown(wxMouseEvent& ME);
63  void OnLMouseUp (wxMouseEvent& ME);
64  void OnRMouseUp (wxMouseEvent& ME);
65  void OnKeyDown (wxKeyEvent& KE);
66  void OnScroll (wxScrollWinEvent& SE);
67 
68  DECLARE_EVENT_TABLE()
69  };
70 }
71 
72 
73 #endif
void Notify_Changed(SubjectT *Subject, const cf::TypeSys::VarBaseT &Var)
Notifies the observer that a variable has changed.
Definition: RenderWindow.cpp:81
Definition: ObserverPattern.hpp:38
void NotifySubjectChanged_Created(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows)
Notifies the observer that one or more windows have been created.
Definition: RenderWindow.cpp:63
This class represents a child frame.
Definition: ChildFrame.hpp:55
Definition: RenderWindow.hpp:20
void NotifySubjectChanged_Deleted(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows)
Notifies the observer that one or more windows have been deleted.
Definition: RenderWindow.cpp:69
void NotifySubjectChanged_Selection(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &OldSelection, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &NewSelection)
This method is called whenever the window selection of a GUI subject changed.
Definition: RenderWindow.cpp:57
void NotifySubjectDies(SubjectT *dyingSubject)
This method is called whenever a subject is about the be destroyed (and become unavailable).
Definition: RenderWindow.cpp:87
Definition: ChildFrame.hpp:35
Definition: GuiDocument.hpp:39
This is the common base class for the VarT classes.
Definition: Variables.hpp:113
Definition: ObserverPattern.hpp:95
void NotifySubjectChanged_Modified(SubjectT *Subject, const ArrayT< IntrusivePtrT< cf::GuiSys::WindowT > > &Windows, WindowModDetailE Detail)
Definition: RenderWindow.cpp:75
This file provides the classes for the Observer pattern as described in the book by the GoF...
Definition: Renderer.hpp:16