3 #include "helpers/ScopeValue.h"
4 #include "helpers/ScopeString.h"
5 #include "ScopeDefines.h"
14 :
public CWindowImpl<CScopeEditCtrl<ValT>, CEdit> {
34 MESSAGE_HANDLER(WM_CHAR,
OnChar)
36 MESSAGE_HANDLER(WM_KEYUP,
OnKeyUp)
39 DEFAULT_REFLECTION_HANDLER()
53 , scope_val(_scopeval)
57 if ( _connectcontrolstate )
63 valueconnection.disconnect();
64 stateconnection.disconnect();
69 if ( SubclassWindow(hWnd) ) {
81 LRESULT
OnChar(UINT uMsg, WPARAM wParam,LPARAM lParam, BOOL& bHandled) {
89 return DefWindowProc(uMsg, wParam, lParam);
94 LRESULT
OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
99 ::PostMessage(GetParent(), WM_NEXTDLGCTL, shiftstate, 0L);
104 return DefWindowProc(uMsg, wParam, lParam);
108 LRESULT
OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
113 return DefWindowProc(uMsg, wParam, lParam);
117 LRESULT
OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
119 return DefWindowProc(uMsg, wParam, lParam);
124 if ( scope_val !=
nullptr )
125 SetWindowText(scope_val->
ToChar().c_str());
133 ::PostMessage(m_hWnd, WM_UPDATECONTROL, NULL, NULL);
138 if ( scope_val !=
nullptr ) {
139 const int32_t length = GetWindowTextLength()+1;
140 std::vector<WCHAR> buff(length, L
' ');
141 GetWindowText(buff.data(), length);
LRESULT OnUpdateControl(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Worker for UpdateControl (explicit specialization for ScopeValue below). ...
boost::signals2::connection ConnectGUI(signalchange_t::slot_type slot)
Connect signal to slot to GUI.
void SetState(const bool &state)
Sets the enabled/disabled state of the control.
bool created
true after window creation
bool AttachToDlgItem(HWND hWnd)
Attach the control to a dialog item.
LRESULT OnChar(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
For ignoring tab and return without beep.
void UpdateControl()
Updates the string inside the control from the ScopeValues' value.
An adapted CEdit control around a ScopeValue.
LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Update scope_val when leaving focus.
bool shiftstate
stores state of shift key
ScopeValue< ValT > *const scope_val
pointer to underlying ScopeValue
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...
std::wstring ToChar() const
Converts value into a wstring.
boost::signals2::connection ConnectState(signalstate_t::slot_type slot)
Connect signal to slot for state changes.
~CScopeEditCtrl()
Disconnects everything.
LRESULT OnKeyUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Resets state of shift key.
void UpdateValue()
Updates the ScopeValue from the string inside the control.
void SetFromString(const std::wstring &str)
Parses a wstring and sets the value accordingly.
boost::signals2::connection valueconnection
The connection object for the control state (connection to the scope_val value change) ...
boost::signals2::connection stateconnection
The connection object for the control state (connection to the scope_val rw state change) ...