Scope
ScopeSliderCtrl.h
1 #pragma once
2 
3 #include "helpers/ScopeNumber.h"
4 #include "ScopeDefines.h" // to get WM_UPDATECONTROL
5 
6 namespace scope {
7  namespace gui {
8 
14  : public CWindowImpl<CScopeSliderCtrl, CTrackBarCtrl> {
15 
16 protected:
18  bool created;
19 
22 
24  boost::signals2::connection stateconnection;
25 
27  boost::signals2::connection valueconnection;
28 
30  const double increment;
31 
33  const double scalefactor;
34 
36  const double offset;
37 
39  const int32_t rangehigh;
40 
42  const int32_t rangelow;
43 
45  bool shiftstate;
46 
47 public:
48  BEGIN_MSG_MAP_EX(CScopeSliderCtrl)
49  MSG_OCM_VSCROLL(OnScroll)
50  MSG_OCM_HSCROLL(OnScroll)
51  MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
52  MESSAGE_HANDLER(WM_KEYUP, OnKeyUp)
53  MESSAGE_HANDLER(WM_UPDATECONTROL, OnUpdateControl)
54  DEFAULT_REFLECTION_HANDLER()
55  END_MSG_MAP()
56 
62  CScopeSliderCtrl(ScopeNumber<double>* _scopenum, const double& _increment = 0, const bool& _connectback = false, const bool& _connectcontrolstate = false);
63 
66 
68  BOOL AttachToDlgItem(HWND hWnd);
69 
74  LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
75 
77  LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
78 
80  void OnScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar);
81 
83  LRESULT OnUpdateControl(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
84  // LRESULT OnUpdateValue(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); not needed, since we do OnScroll
90 
94 
boost::signals2::connection stateconnection
The connection object for the control state (connection to the scopenum rw state change) ...
bool created
true if window created
LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Switches to next control on return or tab and updates ScopeValue scope_val Also sets state of shift k...
LRESULT OnUpdateControl(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Worker for UpdateControl.
LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Resets state of shift key.
const double offset
is ScopeNumber lower limit
bool shiftstate
stores state of shift key
void OnScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
Updates the ScopeNumber from the slider position.
const int32_t rangelow
lower end of the slider range, usually 0
const int32_t rangehigh
the upper end of the slider range (100 if not incrementing, otherwise range/increment) ...
const double scalefactor
scalefactor is increment or range/100 (if not incrementing)
ScopeNumber< double > *const scopenum
Pointer to the underlying ScopeNumber.
An adapted CTrackBarCtrl control around a ScopeNumber.
const double increment
if != 0, then scopenum can only be changed by multiples of increment and the slider should display ti...
boost::signals2::connection valueconnection
The connection object for the control state (connection to the scopenum value change) ...
BOOL AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item and set range and tick frequency.