OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
gauge.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TGauge, a gauge control encapsulation & implementation.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_GAUGE_H)
10#define OWL_GAUGE_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/control.h>
18#include <owl/color.h>
19#include <owl/commctrl.h>
20
21
22namespace owl {
23
24#include <owl/preclass.h>
25
26/// \addtogroup ctrl
27/// @{
28/// \class TGauge
29// ~~~~~ ~~~~~~
30/// A streamable class derived from TControl, TGauge defines the basic behavior of
31/// gauge controls. Gauges are display-only horizontal or vertical controls that
32/// provide duration or analog information about a particular process. A typical use
33/// of a gauge occurs in installation programs where a control provides a graphical
34/// display indicating the percentage of files copied. In general, horizontal gauges
35/// with a broken (dashed-line) bar are used to display short-duration, process
36/// information, and horizontal gauges with a solid bar are used to illustrate
37/// long-duration, process information. Usually, vertical gauges are preferred for
38/// displaying analog information.
39///
40/// Note: In OWLNext 6.32, this class was deprecated and replaced by TProgressBar.
41/// While TGauge is a custom-rendered control, TProgressBar encapsulates the native
42/// Windows common control (Progress Bar).
43//
44class _OWLCLASS TGauge : public TControl {
45 public:
46 TGauge(TWindow* parent,
48 int id,
49 int x, int y, int w, int h = 0,
50 bool isHorizontal = true,
51 int margin = 1,
52 TModule* module = 0);
53
54 TGauge(
55 TWindow* parent,
56 const tstring& title,
57 int id,
58 int x, int y, int w, int h = 0,
59 bool isHorizontal = true,
60 int margin = 1,
61 TModule* module = 0);
62
63 TGauge(TWindow* parent,
64 int id,
65 int x, int y, int w, int h = 0,
66 TModule* module = 0);
67
68 TGauge(TWindow* parent,
69 int resId,
70 TModule* module = 0);
71
72 // Getting & setting gauge properties
73 //
74 void GetRange(int& minValue, int& maxValue) const;
75 int GetStep() const;
76 int GetValue() const;
77
78 void SetRange(int minValue, int maxValue);
79 void SetStep(int step);
80 void SetValue(int value); // !CQ SetPos/GetPos alias?
81 void DeltaValue(int delta);
82 void StepIt();
83 void operator ++(int);
84
85 // Set whether the control is horizontal. This method is useful
86 // for an object coming from a dialog resource. [For objects created
87 // by OWL, use the constructor which accepts a boolean 'isHorizontal'
88 // parameter.
89 //
90 void SetHorizontal(bool horizontal);
91
92 // Set the LED style & sizing as well as the indicator color
93 //
94 void SetLed(int spacing, int thickPercent = 90);
95 void SetColor(const TColor& color);
96 void SetBkgndColor(const TColor& color); // new
97
98 protected:
99
100 void Init(bool isHorizontal, int margin);
101
102 // Override TWindow virtual member functions
103 //
104 auto GetWindowClassName() -> TWindowClassName override;
105 void Paint(TDC&, bool erase, TRect&) override;
106 void SetupWindow() override;
107
108 // Self sent by method Paint(). override this is if you want to
109 // implement a border style that isn't supported
110 //
111 virtual void PaintBorder(TDC& dc);
112
113 // Message response functions
114 //
115 bool EvEraseBkgnd(HDC);
116
118 int Min; ///< Holds the minimum value (in gauge units) displayed on the gauge.
119 int Max; ///< Holds the maximum value (in gauge units) displayed on the gauge.
120 int Value; ///< Holds the current value of the gauge.
121 int Step; ///< Holds the step factor to be used by StepIt operations.
122 int Margin; ///< Contains the border width and height of the gauge.
123
124/// Set to the isHorizontal argument of the constructor. IsHorizontal is true if the
125/// gauge is horizontal and false if it is vertical.
126 int IsHorizontal;
127
128/// Holds the integer value (in gauge units) of the spacing between the broken bars
129/// of the gauge. Note that TGauge does not paint the title while using LED spacing.
130 int LedSpacing;
131
132 int LedThick; ///< Holds the thickness of the broken bar in percent of spacing
133
134 TColor BarColor; ///< Holds the bar or LED color, which defaults to blue.
135
136 private:
137 // Hidden to prevent accidental copying or assignment
138 //
139 TGauge(const TGauge&);
140 TGauge& operator=(const TGauge&);
141
143};
144
145/// @}
146
147#include <owl/posclass.h>
148
149//----------------------------------------------------------------------------
150// Inline implementations
151
152//
153/// This inline implementation gets the minimum and maximum values for the gauge.
154//
155inline void TGauge::GetRange(int& minValue, int& maxValue) const
156{
157 minValue = Min; maxValue = Max;
158}
159
160//
161/// Returns the step factor.
162//
163inline int TGauge::GetStep() const
164{
165 return Step;
166}
167
168//
169/// Returns the current value of the gauge.
170//
171inline int TGauge::GetValue() const
172{
173 return Value;
174}
175
176//
177/// Another way of stepping (calls StepIt)
178//
179inline void TGauge::operator ++(int)
180{
181 StepIt();
182}
183
184/// Specifies whether the control is a horizontal (or vertical) gauge control
185//
187{
188 IsHorizontal = isHorizontal;
189}
190
191} // OWL namespace
192
193
194#endif // OWL_GAUGE_H
Class wrapper for management of color values.
Definition color.h:245
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
A streamable class derived from TControl, TGauge defines the basic behavior of gauge controls.
Definition gauge.h:44
void SetHorizontal(bool horizontal)
Specifies whether the control is a horizontal (or vertical) gauge control.
Definition gauge.h:186
int GetStep() const
Returns the step factor.
Definition gauge.h:163
void StepIt()
Adjusts the active gauge value by the Step increment.
Definition gauge.cpp:228
int GetValue() const
Returns the current value of the gauge.
Definition gauge.h:171
void GetRange(int &minValue, int &maxValue) const
This inline implementation gets the minimum and maximum values for the gauge.
Definition gauge.h:155
void operator++(int)
Another way of stepping (calls StepIt)
Definition gauge.h:179
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
Definition of windowing system color classes.
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338