Added aqua_speed for rite geo 50 tryker
[ryzomcore.git] / nel / tools / 3d / object_viewer / editable_range.cpp
blob28806fc315e82b447e7e0fb56a9c2a3d55e7a194
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // editable_range.cpp : implementation file
20 #include "std_afx.h"
21 #include "object_viewer.h"
22 #include "editable_range.h"
26 #include "range_manager.h"
27 #include "range_selector.h"
30 /////////////////////////////////////////////////////////////////////////////
31 // CEditableRange dialog
34 CEditableRange::CEditableRange(const std::string &id, CParticleWorkspace::CNode *node)
35 : _Id(id), _Node(node)
37 //{{AFX_DATA_INIT(CEditableRange)
38 m_MinRange = _T("");
39 m_MaxRange = _T("");
40 m_Value = _T("");
41 m_SliderPos = 0;
42 //}}AFX_DATA_INIT
49 void CEditableRange::update()
51 updateRange();
52 updateValueFromReader();
55 BOOL CEditableRange::EnableWindow( BOOL bEnable)
57 m_ValueCtrl.EnableWindow(bEnable);
58 m_SliderCtrl.EnableWindow(bEnable);
59 m_UpdateValue.EnableWindow(bEnable);
60 m_SelectRange.EnableWindow(bEnable);
62 UpdateData(FALSE);
64 return CEditAttribDlg::EnableWindow(bEnable);
67 void CEditableRange::init(uint32 x, uint32 y, CWnd *pParent)
69 Create(IDD_EDITABLE_RANGE, pParent);
70 RECT r;
71 GetClientRect(&r);
72 MoveWindow(x, y, r.right, r.bottom);
73 // set the slider size
74 CSliderCtrl *sl = (CSliderCtrl *) GetDlgItem(IDC_SLIDER);
75 ShowWindow(SW_SHOW);
79 void CEditableRange::DoDataExchange(CDataExchange* pDX)
81 CDialog::DoDataExchange(pDX);
82 //{{AFX_DATA_MAP(CEditableRange)
83 DDX_Control(pDX, IDC_SLIDER, m_SliderCtrl);
84 DDX_Control(pDX, IDC_VALUE, m_ValueCtrl);
85 DDX_Control(pDX, IDC_UPDATE_VALUE, m_UpdateValue);
86 DDX_Control(pDX, IDC_SELECT_RANGE, m_SelectRange);
87 DDX_Text(pDX, IDC_MIN_RANGE, m_MinRange);
88 DDX_Text(pDX, IDC_MAX_RANGE, m_MaxRange);
89 DDX_Text(pDX, IDC_VALUE, m_Value);
90 DDX_Slider(pDX, IDC_SLIDER, m_SliderPos);
91 //}}AFX_DATA_MAP
97 BEGIN_MESSAGE_MAP(CEditableRange, CDialog)
98 //{{AFX_MSG_MAP(CEditableRange)
99 ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER, OnReleasedcaptureSlider)
100 ON_BN_CLICKED(IDC_SELECT_RANGE, OnSelectRange)
101 ON_EN_SETFOCUS(IDC_VALUE, OnSetfocusValue)
102 ON_BN_CLICKED(IDC_UPDATE_VALUE, OnUpdateValue)
103 ON_EN_KILLFOCUS(IDC_VALUE, OnKillfocusValue)
104 ON_EN_CHANGE(IDC_VALUE, OnChangeValue)
105 ON_WM_HSCROLL()
106 //}}AFX_MSG_MAP
107 END_MESSAGE_MAP()
109 /////////////////////////////////////////////////////////////////////////////
110 // CEditableRange message handlers
117 BOOL CEditableRange::OnInitDialog()
119 CDialog::OnInitDialog();
121 updateRange();
122 updateValueFromReader();
124 return TRUE; // return TRUE unless you set the focus to a control
125 // EXCEPTION: OCX Property Pages should return FALSE
129 void CEditableRange::OnReleasedcaptureSlider(NMHDR* pNMHDR, LRESULT* pResult)
131 UpdateData();
132 CSliderCtrl *sl = (CSliderCtrl *) GetDlgItem(IDC_SLIDER);
133 if (
134 (sl->GetRangeMax() - sl->GetRangeMin()) != 0
137 updateValueFromSlider(m_SliderPos * 1.f / (sl->GetRangeMax() - sl->GetRangeMin()));
139 else
141 updateValueFromSlider(0);
143 *pResult = 0;
146 void CEditableRange::OnSelectRange()
148 selectRange();
153 void CEditableRange::OnUpdateValue()
155 UpdateData();
156 updateValueFromText();
160 void CEditableRange::emptyDialog(void)
162 m_Value.Empty();
163 m_SliderPos = 0;
164 UpdateData(FALSE);
167 void CEditableRange::OnSetfocusValue()
169 CEdit *ce = (CEdit *) GetDlgItem(IDC_VALUE);
170 ce->PostMessage(EM_SETSEL, 0, -1);
171 ce->Invalidate();
175 void CEditableRange::OnKillfocusValue()
177 // When kill Focus from the edit text, update the value.
178 /*UpdateData();
179 updateValueFromText(); */
183 static void concatEdit2Lines(CEdit &edit)
185 const uint lineLen= 1000;
186 uint n;
187 // retrieve the 2 lines.
188 TCHAR tmp0[2*lineLen];
189 TCHAR tmp1[lineLen];
190 n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0;
191 n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0;
192 // concat and update the CEdit.
193 edit.SetWindowText(_tcscat(tmp0, tmp1));
197 void CEditableRange::OnChangeValue()
199 UpdateData();
200 // Trick to track "Enter" keypress: CEdit are multiline. If GetLineCount()>1, then
201 // user has press enter.
202 if(m_ValueCtrl.GetLineCount()>1)
204 // must ccat 2 lines of the CEdit.
205 concatEdit2Lines(m_ValueCtrl);
206 m_ValueCtrl.GetWindowText(m_Value);
207 updateValueFromText();
211 void CEditableRange::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
213 if (nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK || nSBCode == SB_LINERIGHT || nSBCode == SB_LINELEFT)
215 UpdateData(TRUE);
216 if (nSBCode == SB_THUMBPOSITION || nSBCode == SB_THUMBTRACK)
218 m_SliderPos = nPos;
219 UpdateData(FALSE);
222 CSliderCtrl *sl = (CSliderCtrl *) GetDlgItem(IDC_SLIDER);
223 if (
224 (sl->GetRangeMax() - sl->GetRangeMin()) != 0
227 updateValueFromSlider(m_SliderPos * 1.f / (sl->GetRangeMax() - sl->GetRangeMin()));
229 else
231 updateValueFromSlider(0);
234 CDialog::OnHScroll(nSBCode, nPos, pScrollBar);