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