The Battle for Wesnoth
1.15.9+dev
show_dialog.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
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 2 of the License, or
8
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
#pragma once
16
17
class
surface
;
18
19
#include "
cursor.hpp
"
20
#include "
floating_label.hpp
"
21
#include "
tooltips.hpp
"
22
#include "
video.hpp
"
23
#include "widgets/button.hpp"
24
25
namespace
gui
26
{
27
28
extern
const
int
ButtonHPadding
;
29
extern
const
int
ButtonVPadding
;
30
enum
DIALOG_RESULT
{
31
DIALOG_BACK
=-7,
32
DIALOG_FORWARD
=-6,
33
CREATE_ITEM
=-5,
34
DELETE_ITEM
=-4,
35
ESCAPE_DIALOG
=-3,
//special return used by WML event dialogs
36
CONTINUE_DIALOG
=-2,
37
CLOSE_DIALOG
=-1
38
/* results (0..N) reserved for standard button indices */
39
};
40
41
bool
in_dialog
();
42
43
struct
dialog_manager
:
private
cursor::setter
,
private
font::floating_label_context
{
44
dialog_manager
();
45
~dialog_manager
();
46
47
private
:
48
bool
reset_to
;
49
};
50
51
class
dialog_frame
:
public
video2::draw_layering
{
52
public
:
53
struct
dimension_measurements
{
54
dimension_measurements
();
55
SDL_Rect interior, exterior,
title
, button_row;
56
};
57
class
style
{
58
public
:
59
style
(
const
std::string&
p
,
int
br) : panel(p), blur_radius(br) {}
60
std::string
panel
;
61
int
blur_radius
;
62
};
63
64
//Static members
65
static
const
int
title_border_w
, title_border_h;
66
static
const
style
default_style
;
67
static
const
style
message_style
;
68
static
const
style
preview_style
;
69
static
const
style
titlescreen_style
;
70
71
dialog_frame
(
CVideo
&video,
const
std::string& title=
""
,
72
const
style
& dialog_style=default_style,
73
bool
auto_restore=
true
, std::vector<button*>* buttons=
nullptr
,
74
button
* help_button=
nullptr
);
75
~
dialog_frame
();
76
77
dimension_measurements
layout(
int
x,
int
y,
int
w
,
int
h
);
78
dimension_measurements
layout(
const
SDL_Rect& frame_area);
79
void
set_layout
(
dimension_measurements
&new_dim) { dim_ = new_dim; }
80
dimension_measurements
get_layout
()
const
{
return
dim_; }
81
82
int
top_padding()
const
;
83
int
bottom_padding()
const
;
84
85
void
draw();
86
87
//called by draw
88
void
draw_border();
89
void
draw_background
();
90
91
//also called by layout with null param
92
SDL_Rect draw_title(
CVideo
*video);
93
94
void
set_dirty(
bool
dirty =
true
);
95
96
virtual
void
handle_event(
const
SDL_Event&);
97
void
handle_window_event(
const
SDL_Event& event);
98
99
private
:
100
void
clear_background();
101
102
std::string
title_
;
103
CVideo
&
video_
;
104
const
style
&
dialog_style_
;
105
std::vector<button*>*
buttons_
;
106
button
*
help_button_
;
107
surface_restorer
*
restorer_
;
108
bool
auto_restore_
;
109
dimension_measurements
dim_
;
110
surface
top_, bot_, left_, right_, top_left_, bot_left_,
top_right_
, bot_right_, bg_;
111
bool
have_border_
;
112
bool
dirty_
;
113
};
114
115
}
gui::dialog_frame::preview_style
static const style preview_style
Definition:
show_dialog.hpp:68
gui::dialog_frame::top_right_
surface top_right_
Definition:
show_dialog.hpp:110
gui::dialog_manager::dialog_manager
dialog_manager()
Definition:
show_dialog.cpp:61
video2::draw_layering
Definition:
video.hpp:345
tooltips.hpp
gui::DIALOG_BACK
Definition:
show_dialog.hpp:31
gui::dialog_frame::style::blur_radius
int blur_radius
Definition:
show_dialog.hpp:61
gui::dialog_frame::default_style
static const style default_style
Definition:
show_dialog.hpp:66
gui::dialog_manager::reset_to
bool reset_to
Definition:
show_dialog.hpp:48
gui::dialog_frame::help_button_
button * help_button_
Definition:
show_dialog.hpp:106
CVideo
Definition:
video.hpp:31
gui::in_dialog
bool in_dialog()
Definition:
show_dialog.cpp:56
draw_background
static void draw_background(surface screen, const SDL_Rect &area, const std::string &image)
Definition:
display.cpp:1494
surface_restorer
Definition:
surface.hpp:120
gui
General purpose widgets.
Definition:
tristate_button.cpp:29
gui::dialog_frame::buttons_
std::vector< button * > * buttons_
Definition:
show_dialog.hpp:105
cursor.hpp
gui::dialog_frame::restorer_
surface_restorer * restorer_
Definition:
show_dialog.hpp:107
surface
Definition:
surface.hpp:25
gui::dialog_frame::dimension_measurements
Definition:
show_dialog.hpp:53
h
#define h
cursor::setter
Definition:
cursor.hpp:40
video.hpp
gui::dialog_manager::~dialog_manager
~dialog_manager()
Definition:
show_dialog.cpp:66
gui::dialog_frame::dialog_style_
const style & dialog_style_
Definition:
show_dialog.hpp:104
gui::ButtonHPadding
const int ButtonHPadding
Definition:
show_dialog.cpp:42
gui::dialog_frame
Definition:
show_dialog.hpp:51
gui::dialog_frame::dimension_measurements::title
SDL_Rect title
Definition:
show_dialog.hpp:55
gui::dialog_manager
Definition:
show_dialog.hpp:43
gui::CONTINUE_DIALOG
Definition:
show_dialog.hpp:36
gui::dialog_frame::dirty_
bool dirty_
Definition:
show_dialog.hpp:112
gui::CREATE_ITEM
Definition:
show_dialog.hpp:33
gui::DIALOG_FORWARD
Definition:
show_dialog.hpp:32
gui::DELETE_ITEM
Definition:
show_dialog.hpp:34
gui::dialog_frame::title_
std::string title_
Definition:
show_dialog.hpp:102
gui::dialog_frame::style::style
style(const std::string &p, int br)
Definition:
show_dialog.hpp:59
gui::dialog_frame::title_border_w
static const int title_border_w
Definition:
show_dialog.hpp:65
gui::button
A button is a control that can be pushed to start an action or close a dialog.
Definition:
button.hpp:49
gui::dialog_frame::titlescreen_style
static const style titlescreen_style
Definition:
show_dialog.hpp:69
gui::CLOSE_DIALOG
Definition:
show_dialog.hpp:37
p
mock_party p
Definition:
test_formula_core.cpp:68
font::floating_label_context
structure which will hide all current floating labels, and cause floating labels instantiated after i...
Definition:
floating_label.hpp:27
gui::dialog_frame::dim_
dimension_measurements dim_
Definition:
show_dialog.hpp:109
floating_label.hpp
w
int w
Definition:
function_table.cpp:135
gui::DIALOG_RESULT
DIALOG_RESULT
Definition:
show_dialog.hpp:30
gui::dialog_frame::video_
CVideo & video_
Definition:
show_dialog.hpp:103
gui::dialog_frame::auto_restore_
bool auto_restore_
Definition:
show_dialog.hpp:108
gui::dialog_frame::set_layout
void set_layout(dimension_measurements &new_dim)
Definition:
show_dialog.hpp:79
gui::ESCAPE_DIALOG
Definition:
show_dialog.hpp:35
gui::dialog_frame::get_layout
dimension_measurements get_layout() const
Definition:
show_dialog.hpp:80
gui::dialog_frame::have_border_
bool have_border_
Definition:
show_dialog.hpp:111
gui::ButtonVPadding
const int ButtonVPadding
Definition:
show_dialog.cpp:43
gui::dialog_frame::style::panel
std::string panel
Definition:
show_dialog.hpp:60
gui::dialog_frame::message_style
static const style message_style
Definition:
show_dialog.hpp:67
gui::dialog_frame::style
Definition:
show_dialog.hpp:57
Generated by
1.8.13