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
progressbar.h
Go to the documentation of this file.
1//
2/// \file progressbar.h
3/// Encapsulation for Windows ProgressBar common control
4//
5// Part of OWLNext - the next generation Object Windows Library
6// Copyright (c) 2010-2011 Jogy
7//
8// For more information, including license details, see
9// http://owlnext.sourceforge.net
10//
11
12#if !defined(OWL_PROGRESSBAR_H)
13#define OWL_PROGRESSBAR_H
14
15#include <owl/private/defs.h>
16#if defined(BI_HAS_PRAGMA_ONCE)
17# pragma once
18#endif
19
20#include <owl/control.h>
21#include <owl/color.h>
22#include <owl/commctrl.h>
23#include <utility>
24
25namespace owl {
26
27#include <owl/preclass.h>
28
29/// \addtogroup ctrl
30/// @{
31/// \class TProgressBar
32// ~~~~~ ~~~~~~
33//
35 public:
36 TProgressBar(TWindow* parent,
37 int id,
38 int x, int y, int w, int h = 0,
39 TModule* module = 0);
40
41 TProgressBar(TWindow* parent,
42 int resId,
43 TModule* module = 0);
44
45 // Getting & setting gauge properties
46 //
47 void GetRange(int& minValue, int& maxValue) const;
48 auto GetRange() const -> std::pair<int, int> {return {Min, Max};}
49 int GetStep() const;
50 int GetValue() const;
51 auto GetState() const -> uint;
52
53 void SetRange(int minValue, int maxValue);
54 void SetRange(const std::pair<int, int>& r) {SetRange(r.first, r.second);}
55 void SetStep(int step);
56 void SetValue(int value); // !CQ SetPos/GetPos alias?
57 void DeltaValue(int delta);
58 void StepIt();
59 void operator ++(int);
60 auto SetState(uint) -> uint;
61 void SetMarquee(bool enable, uint timeBetweenUpdates = 0);
62
63 // Set the LED style & sizing as well as the indicator color
64 // Ignored by CommonControl impl.
65 //
66 // NOTE: Invoking these methods may *NOT* be effective if OWL
67 // uses the Common Control support and instead of
68 // emulating the control.
69 //
70 void SetColor(const TColor& color);
71 void SetBkgndColor(const TColor& color); // new
72
73
74 protected:
75
76 // Override TWindow virtual member functions
77 //
78 virtual auto GetWindowClassName() -> TWindowClassName;
79 void SetupWindow();
80
81
83 int Min; ///< Holds the minimum value (in gauge units) displayed on the gauge.
84 int Max; ///< Holds the maximum value (in gauge units) displayed on the gauge.
85 int Value; ///< Holds the current value of the gauge.
86 int Step; ///< Holds the step factor to be used by StepIt operations.
87 int Margin; ///< Contains the border width and height of the gauge.
88 bool Marquee; ///< Enable marquee mode (display indeterminate progress bar).
89 uint MarqueeUpdateTime; ///< Time, in milliseconds, between marquee animation updates. If this parameter is zero, the marquee animation is updated every 30 milliseconds.
90
91 private:
92 // Hidden to prevent accidental copying or assignment
93 //
95 TProgressBar& operator=(const TProgressBar&);
96};
97
98/// @}
99
100#include <owl/posclass.h>
101
102//----------------------------------------------------------------------------
103// Inline implementations
104
105//
106/// This inline implementation gets the minimum and maximum values for the gauge.
107//
108inline void TProgressBar::GetRange(int& minValue, int& maxValue) const
109{
110 minValue = Min; maxValue = Max;
111}
112
113//
114/// Returns the step factor.
115//
116inline int TProgressBar::GetStep() const
117{
118 return Step;
119}
120
121//
122/// Returns the current value of the gauge.
123//
124inline int TProgressBar::GetValue() const
125{
126 return Value;
127 // return CONST_CAST(TProgressBar*, this)->SendMessage(PBM_GETPOS);
128}
129
130//
131/// Returns the state of the progress bar.
132/// \note Wrapper for PBM_GETSTATE.
133/// \see https://msdn.microsoft.com/en-us/library/windows/desktop/bb760834.aspx
134//
135inline auto TProgressBar::GetState() const -> uint
136{
137 return static_cast<uint>(SendMessage(PBM_GETSTATE));
138}
139
140//
141/// Another way of stepping (calls StepIt)
142//
144{
145 StepIt();
146}
147
148} // OWL namespace
149
150
151#endif // OWL_PROGRESSBAR_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
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
int GetStep() const
Returns the step factor.
void StepIt()
Adjusts the active gauge value by the Step increment.
auto GetRange() const -> std::pair< int, int >
Definition progressbar.h:48
int GetValue() const
Returns the current value of the gauge.
void operator++(int)
Another way of stepping (calls StepIt)
auto GetState() const -> uint
Returns the state of the progress bar.
void SetRange(const std::pair< int, int > &r)
Definition progressbar.h:54
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
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
Definition of windowing system color classes.
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338