Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
window.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.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 // window.h
21 
22 #pragma once
23 
24 #include "common/event.h"
25 #include "common/misc.h"
26 #include "common/restext.h"
27 
28 #include "graphics/engine/text.h"
29 
30 #include "ui/button.h"
31 #include "ui/color.h"
32 #include "ui/check.h"
33 #include "ui/key.h"
34 #include "ui/group.h"
35 #include "ui/image.h"
36 #include "ui/label.h"
37 #include "ui/edit.h"
38 #include "ui/editvalue.h"
39 #include "ui/scroll.h"
40 #include "ui/slider.h"
41 #include "ui/list.h"
42 #include "ui/shortcut.h"
43 #include "ui/map.h"
44 #include "ui/gauge.h"
45 #include "ui/compass.h"
46 #include "ui/target.h"
47 #include "ui/control.h"
48 
49 #include <string>
50 
51 namespace Ui {
52 
53 const int MAXWINDOW = 100;
54 
55 
56 class CWindow : public CControl
57 {
58 public:
59  CWindow();
60  ~CWindow();
61 
62  void Flush();
63  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
64  CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
65  CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
66  CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
67  CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
68  CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
69  CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
70  CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
71  CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
72  CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
73  CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
74  CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
75  CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
76  CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
77  CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
78  CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
79  CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
80  CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
81  bool DeleteControl(EventType eventMsg);
82  CControl* SearchControl(EventType eventMsg);
83 
84  EventType GetEventTypeReduce();
85  EventType GetEventTypeFull();
86  EventType GetEventTypeClose();
87 
88  virtual void SetName(std::string name, bool tooltip = true) OVERRIDE;
89 
90  void SetTrashEvent(bool bTrash);
91  bool GetTrashEvent();
92 
93  void SetPos(Math::Point pos);
94  void SetDim(Math::Point dim);
95 
96  void SetMinDim(Math::Point dim);
97  void SetMaxDim(Math::Point dim);
98  Math::Point GetMinDim();
99  Math::Point GetMaxDim();
100 
101  void SetMovable(bool bMode);
102  bool GetMovable();
103 
104  void SetRedim(bool bMode);
105  bool GetRedim();
106 
107  void SetClosable(bool bMode);
108  bool GetClosable();
109 
110  void SetMaximized(bool bMaxi);
111  bool GetMaximized();
112  void SetMinimized(bool bMini);
113  bool GetMinimized();
114  void SetFixed(bool bFix);
115  bool GetFixed();
116 
117  bool GetTooltip(Math::Point pos, std::string &name);
118 
119  bool EventProcess(const Event &event);
120 
121  void Draw();
122 
123 protected:
124  int BorderDetect(Math::Point pos);
125  void AdjustButtons();
126  void MoveAdjust();
127  void DrawVertex(Math::Point pos, Math::Point dim, int icon);
128  void DrawHach(Math::Point pos, Math::Point dim);
129 
130 protected:
131  CControl* m_table[MAXWINDOW];
132 
133  bool m_bTrashEvent;
134  bool m_bMaximized;
135  bool m_bMinimized;
136  bool m_bFixed;
137 
138  Math::Point m_minDim;
139  Math::Point m_maxDim;
140 
141  CButton* m_buttonReduce;
142  CButton* m_buttonFull;
143  CButton* m_buttonClose;
144 
145  bool m_bMovable;
146  bool m_bRedim;
147  bool m_bClosable;
148  bool m_bCapture;
149  Math::Point m_pressPos;
150  int m_pressFlags;
151  Gfx::EngineMouseType m_pressMouse;
152 };
153 
154 
155 }
156 
Definition: gauge.h:34
Definition: map.h:72
Definition: shortcut.h:30
Definition: controller.h:32
Text rendering - CText class.
Definition: list.h:42
Definition: group.h:33
Definition: target.h:40
Definition: compass.h:33
Definition: editvalue.h:46
Definition: button.h:30
Definition: color.h:34
Definition: label.h:32
Definition: slider.h:32
Translation and string resource utilities.
2D point
Definition: point.h:49
Definition: check.h:33
Definition: image.h:34
Key slot control.
EngineMouseType
Type of mouse cursor displayed in-game.
Definition: engine.h:510
CEdit class.
Event types, structs and event queue.
Definition: edit.h:131
Definition: key.h:38
Definition: scroll.h:37
EventType
Type of event message.
Definition: event.h:38
Event sent by system, interface or game.
Definition: event.h:678
Definition: window.h:56
Definition: control.h:66