ScummVM API documentation
dialogbox.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef STARK_UI_DIALOG_BOX_H
23 #define STARK_UI_DIALOG_BOX_H
24 
25 #include "engines/stark/stark.h"
26 #include "engines/stark/ui/window.h"
27 #include "engines/stark/gfx/color.h"
28 
29 #include "common/keyboard.h"
30 #include "common/scummsys.h"
31 
32 namespace Stark {
33 
34 namespace Gfx {
35 class SurfaceRenderer;
36 class Bitmap;
37 }
38 
39 typedef Common::Functor0<void> ConfirmCallback;
40 
41 class VisualText;
42 
49 class DialogBox : public Window {
50 public:
51  DialogBox(StarkEngine *vm, Gfx::Driver *gfx, Cursor *cursor);
52  ~DialogBox() override;
53 
55  void open(const Common::String &message, ConfirmCallback *confirmCallback,
56  const Common::String &confirmLabel, const Common::String &cancelLabel);
57 
59  void close();
60 
62  void onScreenChanged();
63 
65  void onKeyPress(const Common::CustomEventType customType);
66 
67 protected:
68  void onRender() override;
69  void onClick(const Common::Point &pos) override;
70 
71 private:
72  Gfx::Bitmap *loadBackground(Gfx::Driver *gfx);
73  static void drawBevel(Graphics::Surface *surface, const Common::Rect &rect);
74  static Common::Rect centerRect(const Common::Rect &container, const Common::Rect &size);
75 
76  void freeForeground();
77  void recomputeLayout();
78 
79  StarkEngine *_vm;
80 
81  Gfx::SurfaceRenderer *_surfaceRenderer;
82  Gfx::Bitmap *_background;
83  Gfx::Bitmap *_foreground;
84 
85  VisualText *_messageVisual;
86  VisualText *_confirmLabelVisual;
87  VisualText *_cancelLabelVisual;
88 
89  Common::Rect _confirmButtonRect;
90  Common::Rect _cancelButtonRect;
91  Common::Rect _messageRect;
92 
93  const Gfx::Color _textColor = Gfx::Color(0xFF, 0xFF, 0xFF);
94  const Gfx::Color _backgroundColor = Gfx::Color(26, 28, 57);
95 
96  ConfirmCallback *_confirmCallback;
97 };
98 
99 } // End of namespace Stark
100 
101 #endif // STARK_UI_DIALOG_BOX_H
Definition: str.h:59
Definition: surface.h:67
Definition: window.h:54
Definition: rect.h:144
uint32 CustomEventType
Definition: events.h:193
Definition: surfacerenderer.h:36
Definition: driver.h:44
Definition: cursor.h:45
Definition: text.h:44
Definition: console.h:27
Definition: bitmap.h:38
Definition: rect.h:45
Definition: stark.h:91
Definition: dialogbox.h:49
Definition: color.h:30