Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
window.h
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
3 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
4 // *
5 // * This program is free software: you can redistribute it and/or modify
6 // * it under the terms of the GNU General Public License as published by
7 // * the Free Software Foundation, either version 3 of the License, or
8 // * (at your option) any later version.
9 // *
10 // * This program is distributed in the hope that it will be useful,
11 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // * GNU General Public License for more details.
14 // *
15 // * You should have received a copy of the GNU General Public License
16 // * along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 // window.h
19 
20 #pragma once
21 
22 #include "common/event.h"
23 #include "common/misc.h"
24 #include "common/restext.h"
25 
26 #include "graphics/engine/text.h"
27 
28 #include "ui/button.h"
29 #include "ui/color.h"
30 #include "ui/check.h"
31 #include "ui/key.h"
32 #include "ui/group.h"
33 #include "ui/image.h"
34 #include "ui/label.h"
35 #include "ui/edit.h"
36 #include "ui/editvalue.h"
37 #include "ui/scroll.h"
38 #include "ui/slider.h"
39 #include "ui/list.h"
40 #include "ui/shortcut.h"
41 #include "ui/map.h"
42 #include "ui/gauge.h"
43 #include "ui/compass.h"
44 #include "ui/target.h"
45 #include "ui/control.h"
46 
47 #include <string>
48 
49 namespace Ui {
50 
51 const int MAXWINDOW = 100;
52 
53 
54 class CWindow : public CControl
55 {
56 public:
57  CWindow();
58  ~CWindow();
59 
60  void Flush();
61  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
62  CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
63  CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
64  CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
65  CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
66  CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
67  CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
68  CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
69  CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
70  CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
71  CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
72  CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
73  CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
74  CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
75  CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
76  CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
77  CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
78  CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
79  bool DeleteControl(EventType eventMsg);
80  CControl* SearchControl(EventType eventMsg);
81 
82  EventType GetEventTypeReduce();
83  EventType GetEventTypeFull();
84  EventType GetEventTypeClose();
85 
86  virtual void SetName(std::string name, bool tooltip = true) override;
87 
88  void SetTrashEvent(bool bTrash);
89  bool GetTrashEvent();
90 
91  void SetPos(Math::Point pos);
92  void SetDim(Math::Point dim);
93 
94  void SetMinDim(Math::Point dim);
95  void SetMaxDim(Math::Point dim);
96  Math::Point GetMinDim();
97  Math::Point GetMaxDim();
98 
99  void SetMovable(bool bMode);
100  bool GetMovable();
101 
102  void SetRedim(bool bMode);
103  bool GetRedim();
104 
105  void SetClosable(bool bMode);
106  bool GetClosable();
107 
108  void SetMaximized(bool bMaxi);
109  bool GetMaximized();
110  void SetMinimized(bool bMini);
111  bool GetMinimized();
112  void SetFixed(bool bFix);
113  bool GetFixed();
114 
115  bool GetTooltip(Math::Point pos, std::string &name);
116 
117  bool EventProcess(const Event &event);
118 
119  void Draw();
120 
121 protected:
122  int BorderDetect(Math::Point pos);
123  void AdjustButtons();
124  void MoveAdjust();
125  void DrawVertex(Math::Point pos, Math::Point dim, int icon);
126  void DrawHach(Math::Point pos, Math::Point dim);
127 
128 protected:
129  CControl* m_table[MAXWINDOW];
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  CButton* m_buttonReduce;
140  CButton* m_buttonFull;
141  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 }
154 
Definition: gauge.h:32
Definition: map.h:70
Definition: shortcut.h:28
Text rendering - CText class.
Definition: list.h:40
Definition: group.h:30
Definition: target.h:37
Definition: compass.h:31
Definition: editvalue.h:44
Definition: button.h:28
Definition: color.h:32
Definition: label.h:30
Definition: slider.h:30
Translation and string resource utilities.
2D point
Definition: point.h:46
Definition: check.h:31
Definition: image.h:32
Key slot control.
EngineMouseType
Type of mouse cursor displayed in-game.
Definition: engine.h:507
CEdit class.
Event types, structs and event queue.
Definition: edit.h:129
Definition: key.h:34
Definition: scroll.h:35
EventType
Type of event message.
Definition: event.h:35
Event sent by system, interface or game.
Definition: event.h:687
Definition: window.h:54
Definition: control.h:64