From 479a67a731be5a5e8035ea7acce0344c7c605814 Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Mon, 10 Sep 2012 23:29:38 +0200 Subject: Merge with changes from Zaba999 fork. --- src/ui/editvalue.cpp | 94 +++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 46 deletions(-) (limited to 'src/ui/editvalue.cpp') diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 71e06f2..f747c94 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -1,5 +1,6 @@ // * This file is part of the COLOBOT source code // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch +// * Copyright (C) 2012, Polish Portal of Colobot (PPC) // * // * This program is free software: you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by @@ -17,13 +18,13 @@ // editvalue.cpp -#include -#include -#include +//#include +//#include +//#include -#include "common/struct.h" -#include "old/d3dengine.h" -#include "old/math3d.h" +//#include "common/struct.h" +//#include "old/d3dengine.h" +//#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -33,10 +34,11 @@ - +namespace Ui { // Object's constructor. -CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) +//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan) +CEditValue::CEditValue() : CControl () { m_edit = 0; m_buttonUp = 0; @@ -60,28 +62,28 @@ CEditValue::~CEditValue() // Creates a new button. -bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg) +bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) { - CEdit* pe; - CButton* pc; + Ui::CEdit* pe; + Ui::CButton* pc; - if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg(); - CControl::Create(pos, dim, icon, eventMsg); + if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType(); + CControl::Create(pos, dim, icon, eventType); GlintDelete(); - m_edit = new CEdit(m_iMan); - pe = (CEdit*)m_edit; + m_edit = new Ui::CEdit(); + pe = static_cast(m_edit); pe->Create(pos, dim, 0, EVENT_NULL); pe->SetMaxChar(4); - m_buttonUp = new CButton(m_iMan); - pc = (CButton*)m_buttonUp; + m_buttonUp = new Ui::CButton(); + pc = static_cast(m_buttonUp); pc->Create(pos, dim, 49, EVENT_NULL); // ^ pc->SetRepeat(true); - m_buttonDown = new CButton(m_iMan); - pc = (CButton*)m_buttonDown; + m_buttonDown = new Ui::CButton(); + pc = static_cast(m_buttonDown); pc->Create(pos, dim, 50, EVENT_NULL); // v pc->SetRepeat(true); @@ -151,11 +153,11 @@ bool CEditValue::EventProcess(const Event &event) if ( m_edit != 0 ) { - if ( m_edit->RetFocus() && - event.event == EVENT_KEYDOWN && - event.param == VK_RETURN ) + if ( m_edit->GetFocus() && + event.type == EVENT_KEY_DOWN && + event.param == KEY(RETURN) ) { - value = RetValue(); + value = GetValue(); if ( value > m_maxValue ) value = m_maxValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); @@ -163,19 +165,18 @@ bool CEditValue::EventProcess(const Event &event) } if ( !m_edit->EventProcess(event) ) return false; - if ( event.event == m_edit->RetEventMsg() ) + if ( event.type == m_edit->GetEventType() ) { - Event newEvent; - m_event->MakeEvent(newEvent, m_eventMsg); + Event newEvent(m_eventType); m_event->AddEvent(newEvent); } } if ( m_buttonUp != 0 ) { - if ( event.event == m_buttonUp->RetEventMsg() ) + if ( event.type == m_buttonUp->GetEventType() ) { - value = RetValue()+m_stepValue; + value = GetValue()+m_stepValue; if ( value > m_maxValue ) value = m_maxValue; SetValue(value, true); HiliteValue(event); @@ -185,9 +186,9 @@ bool CEditValue::EventProcess(const Event &event) if ( m_buttonDown != 0 ) { - if ( event.event == m_buttonDown->RetEventMsg() ) + if ( event.type == m_buttonDown->GetEventType() ) { - value = RetValue()-m_stepValue; + value = GetValue()-m_stepValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); HiliteValue(event); @@ -195,20 +196,20 @@ bool CEditValue::EventProcess(const Event &event) if ( !m_buttonDown->EventProcess(event) ) return false; } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELUP && + if ( event.type == EVENT_KEY_DOWN && + event.mouseButton.button == 4 && Detect(event.pos) ) { - value = RetValue()+m_stepValue; + value = GetValue()+m_stepValue; if ( value > m_maxValue ) value = m_maxValue; SetValue(value, true); HiliteValue(event); } - if ( event.event == EVENT_KEYDOWN && - event.param == VK_WHEELDOWN && + if ( event.type == EVENT_KEY_DOWN && + event.mouseButton.button == 5 && Detect(event.pos) ) { - value = RetValue()-m_stepValue; + value = GetValue()-m_stepValue; if ( value < m_minValue ) value = m_minValue; SetValue(value, true); HiliteValue(event); @@ -226,7 +227,7 @@ void CEditValue::HiliteValue(const Event &event) if ( m_edit == 0 ) return; - pos = m_edit->RetTextLength(); + pos = m_edit->GetTextLength(); if ( m_type == EVT_100 && pos > 0 ) { pos --; // not only selects the "%" @@ -236,8 +237,9 @@ void CEditValue::HiliteValue(const Event &event) m_edit->SetFocus(true); Event newEvent = event; - newEvent.event = EVENT_FOCUS; - newEvent.param = m_edit->RetEventMsg(); + newEvent.type = EVENT_ACTIVE; + newEvent.active.gain = true; // TODO not much pretty sure about it + newEvent.param = m_edit->GetEventType(); m_event->AddEvent(newEvent); // defocus the other objects } @@ -275,7 +277,7 @@ void CEditValue::SetType(EditValueType type) m_type = type; } -EditValueType CEditValue::RetType() +EditValueType CEditValue::GetType() { return m_type; } @@ -310,15 +312,14 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( bSendMessage ) { - Event newEvent; - m_event->MakeEvent(newEvent, m_eventMsg); + Event newEvent(m_eventType); m_event->AddEvent(newEvent); } } // Return the edited value. -float CEditValue::RetValue() +float CEditValue::GetValue() { char text[100]; float value; @@ -345,7 +346,7 @@ void CEditValue::SetStepValue(float value) m_stepValue = value; } -float CEditValue::RetStepValue() +float CEditValue::GetStepValue() { return m_stepValue; } @@ -358,7 +359,7 @@ void CEditValue::SetMinValue(float value) m_minValue = value; } -float CEditValue::RetMinValue() +float CEditValue::GetMinValue() { return m_minValue; } @@ -371,8 +372,9 @@ void CEditValue::SetMaxValue(float value) m_maxValue = value; } -float CEditValue::RetMaxValue() +float CEditValue::GetMaxValue() { return m_maxValue; } +} -- cgit v1.2.3-1-g7c22 From 36ae984ac77c5545d3d11dde7e37913a8eff0b0d Mon Sep 17 00:00:00 2001 From: Zaba999 Date: Tue, 18 Sep 2012 22:33:28 +0200 Subject: Warnings cleaned, left only those connected to commented out code. --- src/ui/editvalue.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/ui/editvalue.cpp') diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index e5780fd..1188903 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -18,12 +18,6 @@ // editvalue.cpp -//#include -//#include -//#include - -//#include "old/d3dengine.h" -//#include "old/math3d.h" #include "common/event.h" #include "common/misc.h" #include "common/iman.h" @@ -294,7 +288,7 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_INT ) { - sprintf(text, "%d", (int)value); + sprintf(text, "%d", static_cast(value)); } if ( m_type == EVT_FLOAT ) @@ -304,7 +298,7 @@ void CEditValue::SetValue(float value, bool bSendMessage) if ( m_type == EVT_100 ) { - sprintf(text, "%d%%", (int)(value*100.0f)); + sprintf(text, "%d%%", static_cast(value*100.0f)); } m_edit->SetText(text); @@ -321,19 +315,19 @@ void CEditValue::SetValue(float value, bool bSendMessage) float CEditValue::GetValue() { char text[100]; - float value; - - if ( m_edit == 0 ) 0.0f; + float value = 0.0f; - m_edit->GetText(text, 100); - sscanf(text, "%f", &value); - - if ( m_type == EVT_100 ) + if ( m_edit != 0 ) { - value = (value+0.5f)/100.0f; - if ( value < 0.01f ) value = 0.0f; // less than 1%? - } + m_edit->GetText(text, 100); + sscanf(text, "%f", &value); + if ( m_type == EVT_100 ) + { + value = (value+0.5f)/100.0f; + if ( value < 0.01f ) value = 0.0f; // less than 1%? + } + } return value; } -- cgit v1.2.3-1-g7c22 From 1a79137e904eb07c17df2596e6b8aa9310ff22bd Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 21:45:41 +0200 Subject: Mouse wheel fixes --- src/ui/editvalue.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui/editvalue.cpp') diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 1188903..0ee41b3 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -189,9 +189,9 @@ bool CEditValue::EventProcess(const Event &event) if ( !m_buttonDown->EventProcess(event) ) return false; } - if ( event.type == EVENT_KEY_DOWN && - event.mouseButton.button == 4 && - Detect(event.pos) ) + if (event.type == EVENT_MOUSE_WHEEL && + event.mouseWheel.dir == WHEEL_UP && + Detect(event.mouseWheel.pos)) { value = GetValue()+m_stepValue; if ( value > m_maxValue ) value = m_maxValue; @@ -199,8 +199,8 @@ bool CEditValue::EventProcess(const Event &event) HiliteValue(event); } if ( event.type == EVENT_KEY_DOWN && - event.mouseButton.button == 5 && - Detect(event.pos) ) + event.mouseWheel.dir == WHEEL_DOWN && + Detect(event.mouseWheel.pos)) { value = GetValue()-m_stepValue; if ( value < m_minValue ) value = m_minValue; -- cgit v1.2.3-1-g7c22 From 57d33d79ea570773d84ad81d4a61f50e079979ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Konopacki?= Date: Wed, 19 Sep 2012 22:17:28 +0200 Subject: Changes in Ui, solves part of #47 --- src/ui/editvalue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/editvalue.cpp') diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp index 0ee41b3..3b819b3 100644 --- a/src/ui/editvalue.cpp +++ b/src/ui/editvalue.cpp @@ -148,7 +148,7 @@ bool CEditValue::EventProcess(const Event &event) { if ( m_edit->GetFocus() && event.type == EVENT_KEY_DOWN && - event.param == KEY(RETURN) ) + event.key.key == KEY(RETURN) ) { value = GetValue(); if ( value > m_maxValue ) value = m_maxValue; -- cgit v1.2.3-1-g7c22