Scope
ScopeCheckBoxCtrl.h
1 #pragma once
2 
3 #include "helpers/ScopeValue.h"
4 #include "ScopeDefines.h"
5 
6 namespace scope {
7  namespace gui {
8 
12  public CWindowImpl<CScopeCheckBoxCtrl, CButton> {
13 
14 protected:
16  bool created;
17 
20 
22  bool shiftstate;
23 
25  boost::signals2::connection stateconnection;
26 
28  boost::signals2::connection valueconnection;
29 
30 public:
31  BEGIN_MSG_MAP_EX(CScopeCheckBoxCtrl)
32  MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
33  MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
34  MESSAGE_HANDLER(WM_UPDATECONTROL, OnUpdateControl)
35  MSG_OCM_COMMAND(OnReflectedCommand)
36  DEFAULT_REFLECTION_HANDLER()
37  END_MSG_MAP()
38 
43  CScopeCheckBoxCtrl(ScopeValue<bool>* _scopeval, const bool& _connectback = false, const bool& _connectcontrolstate = false);
44 
47 
49  bool AttachToDlgItem(HWND hWnd);
50 
55  void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl);
56 
59  LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
60 
62  LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
63 
65  LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
66 
68  LRESULT OnUpdateControl(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
75  void UpdateControl();
76 
78  void UpdateValue();
82  void SetState(const bool& state);
83 };
84 
85 }
86 
87 }
LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Resets state of shift key.
bool created
true after window creation
void SetState(const bool &state)
Sets the enabled/disabled state of the control.
boost::signals2::connection valueconnection
The connection object for the control state (connection to the scope_val value change) ...
void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
Updates value on reflected BN_CLICKED.
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 OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Update scope_val when leaving focus.
ScopeValue< bool > *const scope_val
pointer to underlying ScopeValue
bool shiftstate
stores state of shift key
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.
boost::signals2::connection stateconnection
The connection object for the control state (connection to the scopenum rw state change) ...
void UpdateValue()
Updates the ScopeValue from the string inside the control.
An adapted CButton control as checkbox around a ScopeValue.
void UpdateControl()
Updates the string inside the control from the ScopeValues' value.