GEStatusBar.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "GEApp.h"
  23. rvGEStatusBar::rvGEStatusBar ( )
  24. {
  25. mSimple = true;
  26. mZoom = 0;
  27. mTriangles = 0;
  28. }
  29. /*
  30. ================
  31. rvGEStatusBar::Create
  32. Creates a new status bar
  33. ================
  34. */
  35. bool rvGEStatusBar::Create ( HWND parent, UINT id, bool visible )
  36. {
  37. mWnd = CreateStatusWindow ( WS_CHILD|WS_VISIBLE|WS_BORDER, "", parent, id );
  38. if ( !mWnd )
  39. {
  40. return false;
  41. }
  42. Show ( visible );
  43. return true;
  44. }
  45. /*
  46. ================
  47. rvGEStatusBar::Resize
  48. Resizes the status bar and updates the content
  49. ================
  50. */
  51. void rvGEStatusBar::Resize ( int width, int height )
  52. {
  53. SendMessage ( mWnd, WM_SIZE, 0, MAKELONG(width,height) );
  54. Update ( );
  55. }
  56. /*
  57. ================
  58. rvGEStatusBar::Update
  59. Updates the status bar by setting up each part's width and text
  60. ================
  61. */
  62. void rvGEStatusBar::Update ( void )
  63. {
  64. RECT rStatus;
  65. SIZE zoomSize;
  66. SIZE trisSize;
  67. int parts[5];
  68. GetWindowRect ( mWnd, &rStatus );
  69. if ( mSimple )
  70. {
  71. parts[0] = -1;
  72. SendMessage ( mWnd, SB_SETPARTS, 1, (LONG)parts );
  73. SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) "" );
  74. }
  75. else
  76. {
  77. zoomSize.cx = 85;
  78. trisSize.cx = 65;
  79. parts[0] = (rStatus.right - rStatus.left) - zoomSize.cx - trisSize.cx - 40;
  80. parts[1] = parts[0] + trisSize.cx;
  81. parts[2] = parts[1] + zoomSize.cx;
  82. parts[3] = parts[2] + 40;
  83. parts[4] = -1;
  84. SendMessage ( mWnd, SB_SETPARTS, 5, (LONG)parts );
  85. SendMessage ( mWnd, SB_SETTEXT, 0, (LPARAM) "" );
  86. SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) va(" Tris: %d", mTriangles ) );
  87. SendMessage ( mWnd, SB_SETTEXT, 2, (LPARAM) va(" Zoom: %d%%", mZoom ) );
  88. }
  89. }
  90. /*
  91. ================
  92. rvGEStatusBar::Show
  93. Shows and hides the status bar
  94. ================
  95. */
  96. void rvGEStatusBar::Show ( bool visible )
  97. {
  98. gApp.GetOptions().SetStatusBarVisible ( visible );
  99. ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
  100. }