Colobot
window.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 "ui/controls/control.h"
23 
24 #include "ui/controls/button.h"
25 #include "ui/controls/check.h"
26 #include "ui/controls/color.h"
27 #include "ui/controls/control.h"
28 #include "ui/controls/edit.h"
29 #include "ui/controls/editvalue.h"
30 #include "ui/controls/enumslider.h"
31 #include "ui/controls/gauge.h"
32 #include "ui/controls/group.h"
33 #include "ui/controls/image.h"
34 #include "ui/controls/key.h"
35 #include "ui/controls/label.h"
36 #include "ui/controls/list.h"
37 #include "ui/controls/map.h"
38 #include "ui/controls/scroll.h"
39 #include "ui/controls/shortcut.h"
40 #include "ui/controls/slider.h"
41 #include "ui/controls/target.h"
42 
43 #include <memory>
44 #include <string>
45 #include <vector>
46 
47 namespace Ui
48 {
49 
50 class CWindow : public CControl
51 {
52 public:
53  CWindow();
54  ~CWindow();
55 
56  void Flush();
57  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) override;
58  CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
59  CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
60  CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
61  CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
62  CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
63  CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
64  CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
65  CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
66  CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
67  CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
68  CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
69  CEnumSlider* CreateEnumSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
70  CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
71  CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
72  CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
73  CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
74  CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
75  bool DeleteControl(EventType eventMsg);
76  CControl* SearchControl(EventType eventMsg);
77 
78  EventType GetEventTypeReduce();
79  EventType GetEventTypeFull();
80  EventType GetEventTypeClose();
81 
82  void SetName(std::string name, bool tooltip = true) override;
83 
84  void SetTrashEvent(bool bTrash);
85  bool GetTrashEvent();
86 
87  void SetPos(Math::Point pos) override;
88  void SetDim(Math::Point dim) override;
89 
90  void SetMinDim(Math::Point dim);
91  void SetMaxDim(Math::Point dim);
92  Math::Point GetMinDim();
93  Math::Point GetMaxDim();
94 
95  void SetMovable(bool bMode);
96  bool GetMovable();
97 
98  void SetRedim(bool bMode);
99  bool GetRedim();
100 
101  void SetClosable(bool bMode);
102  bool GetClosable();
103 
104  void SetMaximized(bool bMaxi);
105  bool GetMaximized();
106  void SetMinimized(bool bMini);
107  bool GetMinimized();
108  void SetFixed(bool bFix);
109  bool GetFixed();
110 
111  bool GetTooltip(Math::Point pos, std::string &name) override;
112 
113  bool EventProcess(const Event &event) override;
114 
115  void Draw() override;
116 
117  void SetFocus(CControl* focusControl) override;
118 
119 protected:
120  int BorderDetect(Math::Point pos);
121  void AdjustButtons();
122  void MoveAdjust();
123  void DrawVertex(Math::Point pos, Math::Point dim, int icon);
124  void DrawHach(Math::Point pos, Math::Point dim);
125  template<typename ControlClass>
126  ControlClass* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
127 
128 protected:
129  std::vector<std::unique_ptr<CControl>> m_controls;
130 
131  bool m_bTrashEvent;
132  bool m_bMaximized;
133  bool m_bMinimized;
134  bool m_bFixed;
135 
136  Math::Point m_minDim;
137  Math::Point m_maxDim;
138 
139  std::unique_ptr<CButton> m_buttonReduce;
140  std::unique_ptr<CButton> m_buttonFull;
141  std::unique_ptr<CButton> m_buttonClose;
142 
143  bool m_bMovable;
144  bool m_bRedim;
145  bool m_bClosable;
146  bool m_bCapture;
147  Math::Point m_pressPos;
148  int m_pressFlags;
149  Gfx::EngineMouseType m_pressMouse;
150 };
151 
152 
153 }
Definition: gauge.h:27
Definition: map.h:69
Definition: shortcut.h:29
Definition: robotmain.h:107
Definition: list.h:44
Definition: group.h:33
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
EngineMouseType
Type of mouse cursor displayed in-game.
Definition: engine.h:445
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: control.h:64