Colobot
editvalue.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 
23 #include "ui/controls/control.h"
24 
25 #include <memory>
26 
27 namespace Gfx
28 {
29 class CEngine;
30 }
31 
32 namespace Ui
33 {
34 
35 enum EditValueType
36 {
37  EVT_INT = 1, // integer
38  EVT_FLOAT = 2, // float value
39  EVT_100 = 3, // percent (0 .. 1)
40 };
41 
42 class CEdit;
43 class CButton;
44 class CInterface;
45 
46 
47 
48 class CEditValue : public CControl
49 {
50 public:
51  CEditValue();
52  virtual ~CEditValue();
53 
54  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override;
55 
56  void SetPos(Math::Point pos) override;
57  void SetDim(Math::Point dim) override;
58 
59  bool EventProcess(const Event &event) override;
60  void Draw() override;
61 
62  void SetType(EditValueType type);
63  EditValueType GetType();
64 
65  void SetValue(float value, bool bSendMessage=false);
66  float GetValue();
67 
68  void SetStepValue(float value);
69  float GetStepValue();
70 
71  void SetMinValue(float value);
72  float GetMinValue();
73 
74  void SetMaxValue(float value);
75  float GetMaxValue();
76 
77  void SetInterface(Ui::CInterface* interface);
78 
79 protected:
80  void MoveAdjust();
81  void HiliteValue(const Event &event);
82 
83  Ui::CInterface* m_interface;
84  std::unique_ptr<Ui::CEdit> m_edit;
85  std::unique_ptr<Ui::CButton> m_buttonUp;
86  std::unique_ptr<Ui::CButton> m_buttonDown;
87  EditValueType m_type;
88  float m_stepValue;
89  float m_minValue;
90  float m_maxValue;
91 };
92 
93 
94 }
Definition: robotmain.h:107
Definition: editvalue.h:48
2D point
Definition: point.h:50
Namespace for (new) graphics code.
Definition: app.h:49
EventType
Type of event message.
Definition: event.h:41
Event sent by system, interface or game.
Definition: event.h:709
Definition: interface.h:58
Definition: control.h:64