2DView.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Copyright (C) 1999-2006 Id Software, Inc. and contributors.
  3. For a list of contributors, see the accompanying CONTRIBUTORS file.
  4. This file is part of GtkRadiant.
  5. GtkRadiant is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. GtkRadiant is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GtkRadiant; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. //-----------------------------------------------------------------------------
  18. //
  19. // DESCRIPTION:
  20. // a class to provide basic services for 2D view of a world
  21. // window <-> local 2D space transforms
  22. // snap to grid
  23. // TODO: this one could be placed under an interface, and provided to the editor as a service
  24. #ifndef _2DVIEW_H_
  25. #define _2DVIEW_H_
  26. class C2DView
  27. {
  28. enum E2DViewState { View_Idle, View_Move } ViewState;
  29. int m_xPosMove, m_yPosMove;
  30. float m_MinsMove[2], m_MaxsMove[2];
  31. qboolean m_bDoGrid;
  32. float m_GridStep[2];
  33. qboolean m_bPopup;
  34. public:
  35. RECT m_rect;
  36. float m_Mins[2],m_Maxs[2],m_Center[2];
  37. C2DView()
  38. {
  39. ViewState = View_Idle;
  40. m_bDoGrid = false;
  41. m_bPopup = false;
  42. }
  43. ~C2DView() { }
  44. void SetGrid( float xGridStep, float yGridStep )
  45. { m_bDoGrid = true; m_GridStep[0] = xGridStep; m_GridStep[1] = yGridStep; }
  46. // get window coordinates for space coordinates
  47. void WindowForSpace( int &x, int &y, const float c[2]);
  48. void SpaceForWindow( float c[2], int x, int y);
  49. void GridForWindow( float c[2], int x, int y);
  50. qboolean DoesSelect( int x, int y, float c[2] );
  51. void PreparePaint();
  52. bool OnRButtonDown (int x, int y);
  53. bool OnMouseMove (int x, int y);
  54. bool OnRButtonUp (int x, int y);
  55. bool OnKeyDown (char *s);
  56. void ZoomIn();
  57. void ZoomOut();
  58. };
  59. #endif