Colobot
interface.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 #include "common/event.h"
23 #include "common/misc.h"
24 
25 #include "graphics/engine/camera.h"
26 #include "graphics/engine/engine.h"
27 
28 #include "math/point.h"
29 
30 #include "ui/controls/button.h"
31 #include "ui/controls/check.h"
32 #include "ui/controls/color.h"
33 #include "ui/controls/control.h"
34 #include "ui/controls/edit.h"
35 #include "ui/controls/editvalue.h"
36 #include "ui/controls/enumslider.h"
37 #include "ui/controls/group.h"
38 #include "ui/controls/image.h"
39 #include "ui/controls/key.h"
40 #include "ui/controls/label.h"
41 #include "ui/controls/list.h"
42 #include "ui/controls/map.h"
43 #include "ui/controls/scroll.h"
44 #include "ui/controls/shortcut.h"
45 #include "ui/controls/slider.h"
46 #include "ui/controls/target.h"
47 #include "ui/controls/window.h"
48 
49 #include <memory>
50 #include <string>
51 #include <vector>
52 
53 namespace Ui
54 {
55 
56 const int MAXCONTROL = 100;
57 
59 {
60 public:
61  CInterface();
62  ~CInterface();
63 
64  bool EventProcess(const Event &event);
65  bool GetTooltip(Math::Point pos, std::string &name);
66 
67  void Flush();
68  CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
69  CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
70  CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
71  CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
72  CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
73  CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
74  CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
75  CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
76  CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
77  CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
78  CEnumSlider* CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
79  CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
80  CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
81  CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
82 
83  CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
84  CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
85  CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
86 
87  bool DeleteControl(EventType eventMsg);
88  CControl* SearchControl(EventType eventMsg);
89 
90  void Draw();
91 
92  void SetFocus(CControl* focusControl);
93 
94 protected:
95  int GetNextFreeControl();
96 
97  template <typename ControlClass>
98  ControlClass* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
99 
100  CEventQueue* m_event;
101  Gfx::CEngine* m_engine;
102  Gfx::CCamera* m_camera;
103  std::array<std::unique_ptr<CControl>, MAXCONTROL> m_controls;
104 };
105 
106 
107 } // namespace Ui
Main graphics engine - CEngine class.
Definition: map.h:69
Definition: shortcut.h:29
Definition: robotmain.h:107
Camera handling - CCamera class.
Point struct and related functions.
Definition: list.h:44
Definition: group.h:33
Global event queue.
Definition: event.h:840
Definition: target.h:36
Definition: editvalue.h:48
Definition: button.h:29
Definition: color.h:34
Definition: label.h:31
Definition: slider.h:31
Key slot control.
2D point
Definition: point.h:50
Definition: check.h:33
Definition: image.h:34
Camera moving in 3D scene.
Definition: camera.h:134
The graphics engine.
Definition: engine.h:620
Event types, structs and event queue.
Definition: edit.h:112
Definition: enumslider.h:30
Definition: key.h:39
Definition: scroll.h:38
EventType
Type of event message.
Definition: event.h:41
Event sent by system, interface or game.
Definition: event.h:709
Definition: window.h:50
Definition: interface.h:58
Definition: control.h:64