doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEStatusBar.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 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.
23 
24 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.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "GEApp.h"
33 
35 {
36  mSimple = true;
37  mZoom = 0;
38  mTriangles = 0;
39 }
40 
41 /*
42 ================
43 rvGEStatusBar::Create
44 
45 Creates a new status bar
46 ================
47 */
48 bool rvGEStatusBar::Create ( HWND parent, UINT id, bool visible )
49 {
50  mWnd = CreateStatusWindow ( WS_CHILD|WS_VISIBLE|WS_BORDER, "", parent, id );
51 
52  if ( !mWnd )
53  {
54  return false;
55  }
56 
57  Show ( visible );
58 
59  return true;
60 }
61 
62 /*
63 ================
64 rvGEStatusBar::Resize
65 
66 Resizes the status bar and updates the content
67 ================
68 */
70 {
71  SendMessage ( mWnd, WM_SIZE, 0, MAKELONG(width,height) );
72 
73  Update ( );
74 }
75 
76 /*
77 ================
78 rvGEStatusBar::Update
79 
80 Updates the status bar by setting up each part's width and text
81 ================
82 */
83 void rvGEStatusBar::Update ( void )
84 {
85  RECT rStatus;
86  SIZE zoomSize;
87  SIZE trisSize;
88  int parts[5];
89 
90  GetWindowRect ( mWnd, &rStatus );
91 
92  if ( mSimple )
93  {
94  parts[0] = -1;
95 
96  SendMessage ( mWnd, SB_SETPARTS, 1, (LONG)parts );
97  SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) "" );
98  }
99  else
100  {
101  zoomSize.cx = 85;
102  trisSize.cx = 65;
103 
104  parts[0] = (rStatus.right - rStatus.left) - zoomSize.cx - trisSize.cx - 40;
105  parts[1] = parts[0] + trisSize.cx;
106  parts[2] = parts[1] + zoomSize.cx;
107  parts[3] = parts[2] + 40;
108  parts[4] = -1;
109 
110  SendMessage ( mWnd, SB_SETPARTS, 5, (LONG)parts );
111  SendMessage ( mWnd, SB_SETTEXT, 0, (LPARAM) "" );
112  SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) va(" Tris: %d", mTriangles ) );
113  SendMessage ( mWnd, SB_SETTEXT, 2, (LPARAM) va(" Zoom: %d%%", mZoom ) );
114  }
115 }
116 
117 /*
118 ================
119 rvGEStatusBar::Show
120 
121 Shows and hides the status bar
122 ================
123 */
124 void rvGEStatusBar::Show ( bool visible )
125 {
126  gApp.GetOptions().SetStatusBarVisible ( visible );
127  ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
128 }
void Resize(int width, int height)
Definition: GEStatusBar.cpp:69
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
void Update(void)
Definition: GEStatusBar.cpp:83
bool Create(HWND parent, UINT id, bool visible=true)
Definition: GEStatusBar.cpp:48
rvGEApp gApp
Definition: guied.cpp:41
rvGEOptions & GetOptions(void)
Definition: GEApp.h:163
void SetStatusBarVisible(bool vis)
Definition: GEOptions.h:160
GLenum GLsizei width
Definition: glext.h:2846
void Show(bool state)
GLenum GLsizei GLsizei height
Definition: glext.h:2856
long LONG
char * va(const char *fmt,...)
Definition: Str.cpp:1568