Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2263 kivins 1
//## begin module%1.7%.codegen_version preserve=yes
2
//   Read the documentation to learn more about C++ code generator
3
//   versioning.
4
//## end module%1.7%.codegen_version
5
 
6
//## begin module%42007ECF0011.cm preserve=no
7
//## end module%42007ECF0011.cm
8
 
9
//## begin module%42007ECF0011.cp preserve=no
10
//	C O P Y R I G H T   N O T I C E
11
//	This material is confidential to ERG and may not be disclosed in whole
12
//	or in part to any third party nor used in any manner whatsoever other
13
//	than for the purposes expressly consented to by ERG in writing.
14
//
15
//	This material is also copyright and may not be reproduced, stored in a
16
//	retrieval system or transmitted in any form or by any means in whole or
17
//	in part without the express written consent of ERG.
18
//## end module%42007ECF0011.cp
19
 
20
//## Module: ProgressBar%42007ECF0011; Pseudo Package body
21
//## Subsystem: MASS::Dev::Tools::TxnTestManager::src%41F5A79001E4
22
//## Source file: Z:\MASS_Dev\Tools\TxnTestManager\src\ProgressBar.cpp
23
 
24
//## begin module%42007ECF0011.additionalIncludes preserve=no
25
//## end module%42007ECF0011.additionalIncludes
26
 
27
//## begin module%42007ECF0011.includes preserve=yes
28
#include <algorithm>
29
//## end module%42007ECF0011.includes
30
 
31
// ProgressBar
32
#include "ProgressBar.h"
33
//## begin module%42007ECF0011.additionalDeclarations preserve=yes
34
#define GREEN 1
35
//## end module%42007ECF0011.additionalDeclarations
36
 
37
 
38
// Class ProgressBar 
39
 
40
//## Operation: ProgressBar%42007F04030F
41
ProgressBar::ProgressBar (TWinControl *owner)
42
  //## begin ProgressBar::ProgressBar%42007F04030F.hasinit preserve=no
43
      : m_percent(0),
44
        m_position(0),
45
        m_progressBar(0),
46
        m_total(0)
47
  //## end ProgressBar::ProgressBar%42007F04030F.hasinit
48
  //## begin ProgressBar::ProgressBar%42007F04030F.initialization preserve=yes
49
  //## end ProgressBar::ProgressBar%42007F04030F.initialization
50
{
51
  //## begin ProgressBar::ProgressBar%42007F04030F.body preserve=yes
52
 
53
#ifdef ADV_PROGRESS_BAR
54
	m_progressBar = new TAdvProgressBar( owner );
55
	m_progressBar->Parent				= owner;
56
	m_progressBar->Steps				= 10;
57
	m_progressBar->Position				= 0;
58
	m_progressBar->ShowBorder			= false;
59
	m_progressBar->ShowGradient			= true;
60
	m_progressBar->ShowPercentage		= true;
61
	m_progressBar->Stacked				= false;
62
	m_progressBar->CompletionSmooth		= false;
63
	m_progressBar->Visible				= false;
64
 
65
	#if GREEN
66
		#define FROM_COLOUR 0x006AA676
67
		#define TO_COLOUR   0x00BAE3C3
68
	#else
69
		#define FROM_COLOUR 0x00C961AD
70
		#define TO_COLOUR   0x00FFBCEF
71
	#endif
72
	m_progressBar->Level0Color			= Graphics::TColor( FROM_COLOUR );
73
	m_progressBar->Level0ColorTo		= Graphics::TColor( TO_COLOUR );
74
	m_progressBar->Level1Color			= Graphics::TColor( FROM_COLOUR );
75
	m_progressBar->Level1ColorTo		= Graphics::TColor( TO_COLOUR );
76
	m_progressBar->Level2Color			= Graphics::TColor( FROM_COLOUR );
77
	m_progressBar->Level2ColorTo		= Graphics::TColor( TO_COLOUR );
78
	m_progressBar->Level3Color			= Graphics::TColor( FROM_COLOUR );
79
	m_progressBar->Level3ColorTo		= Graphics::TColor( TO_COLOUR );
80
#else
81
	m_progressBar = new TProgressBar ( StatusBar );
82
	m_progressBar->Parent = StatusBar;
83
	m_progressBar->Step     = 10;
84
	m_progressBar->Max      = 100;	// We've normalised to percent.
85
	m_progressBar->Position = 0;
86
	m_progressBar->Visible = false;
87
#endif
88
 
89
  //## end ProgressBar::ProgressBar%42007F04030F.body
90
}
91
 
92
 
93
ProgressBar::~ProgressBar()
94
{
95
  //## begin ProgressBar::~ProgressBar%42007ECF0011_dest.body preserve=yes
96
 
97
	delete m_progressBar;
98
	m_progressBar = 0;  
99
 
100
  //## end ProgressBar::~ProgressBar%42007ECF0011_dest.body
101
}
102
 
103
 
104
 
105
//## Other Operations (implementation)
106
//## Operation: close%4200859302A4
107
void ProgressBar::close ()
108
{
109
  //## begin ProgressBar::close%4200859302A4.body preserve=yes
110
 
111
	m_progressBar->Hide();
112
	m_percent	= 0;
113
	m_position	= 0;
114
 
115
  //## end ProgressBar::close%4200859302A4.body
116
}
117
 
118
//## Operation: increment%4200923803B3
119
void ProgressBar::increment (const unsigned int &delta)
120
{
121
  //## begin ProgressBar::increment%4200923803B3.body preserve=yes
122
 
123
	update( m_position + delta );
124
 
125
  //## end ProgressBar::increment%4200923803B3.body
126
}
127
 
128
//## Operation: open%4200813001F0
129
void ProgressBar::open (const unsigned int &total, const unsigned int &position)
130
{
131
  //## begin ProgressBar::open%4200813001F0.body preserve=yes
132
 
133
	m_total		= total;
134
	m_position	= position;
135
	m_percent	= ( m_total
136
		? ( static_cast< int >( position / double( m_total ) * 100.0 ) )
137
		: 100.0 );
138
 
139
#ifdef ADV_PROGRESS_BAR
140
	m_progressBar->Show();
141
	m_progressBar->Position = m_percent;
142
#else
143
	m_progressBar->Show();
144
	m_progressBar->Position = m_percent;
145
#endif
146
 
147
  //## end ProgressBar::open%4200813001F0.body
148
}
149
 
150
//## Operation: resize%4200826C0074
151
void ProgressBar::resize (const int &top, const int &left, const int &width, const int &height)
152
{
153
  //## begin ProgressBar::resize%4200826C0074.body preserve=yes
154
 
155
#ifdef ADV_PROGRESS_BAR
156
	m_progressBar->Top = top + 2;
157
	m_progressBar->Left = left + 4;
158
	m_progressBar->Width = width - 6;
159
	m_progressBar->Height = height - 4;
160
#else
161
	m_progressBar->Top = top;
162
	m_progressBar->Left = left + 2;
163
	m_progressBar->Width = width - 2;
164
	m_progressBar->Height = height;
165
#endif
166
 
167
  //## end ProgressBar::resize%4200826C0074.body
168
}
169
 
170
//## Operation: update%420085F6011D
171
void ProgressBar::update (const unsigned int &position)
172
{
173
  //## begin ProgressBar::update%420085F6011D.body preserve=yes
174
 
175
	// Do this only if we're open.  	
176
	if ( m_total )
177
	{
178
		m_position	= position;
179
		const unsigned int percent = ( static_cast< int >( position / double( m_total ) * 100.0 ) );
180
		if ( m_percent != percent )
181
		{
182
			m_percent	= std::min< int >( percent, 100 );
183
 
184
#ifdef ADV_PROGRESS_BAR
185
			m_progressBar->Position = m_percent;
186
#else
187
			m_progressBar->Position = m_percent;
188
#endif
189
		}
190
	}
191
 
192
  //## end ProgressBar::update%420085F6011D.body
193
}
194
 
195
// Additional Declarations
196
  //## begin ProgressBar%42007ECF0011.declarations preserve=yes
197
  //## end ProgressBar%42007ECF0011.declarations
198
 
199
//## begin module%42007ECF0011.epilog preserve=yes
200
//## end module%42007ECF0011.epilog