The Battle for Wesnoth
1.15.11+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
68
dialog_frame
(
CVideo
&video,
const
std::string& title=
""
,
69
const
style
& dialog_style=default_style,
70
bool
auto_restore=
true
, std::vector<button*>* buttons=
nullptr
,
71
button
* help_button=
nullptr
);
72
~
dialog_frame
();
73
74
dimension_measurements
layout(
int
x,
int
y,
int
w
,
int
h
);
75
dimension_measurements
layout(
const
SDL_Rect& frame_area);
76
void
set_layout
(
dimension_measurements
&new_dim) { dim_ = new_dim; }
77
dimension_measurements
get_layout
()
const
{
return
dim_; }
78
79
int
top_padding()
const
;
80
int
bottom_padding()
const
;
81
82
void
draw();
83
84
//called by draw
85
void
draw_border();
86
void
draw_background
();
87
88
//also called by layout with null param
89
SDL_Rect draw_title(
CVideo
*video);
90
91
void
set_dirty(
bool
dirty =
true
);
92
93
virtual
void
handle_event(
const
SDL_Event&);
94
void
handle_window_event(
const
SDL_Event& event);
95
96
private
:
97
void
clear_background();
98
99
std::string
title_
;
100
CVideo
&
video_
;
101
const
style
&
dialog_style_
;
102
std::vector<button*>*
buttons_
;
103
button
*
help_button_
;
104
surface_restorer
*
restorer_
;
105
bool
auto_restore_
;
106
dimension_measurements
dim_
;
107
surface
top_, bot_, left_, right_, top_left_, bot_left_,
top_right_
, bot_right_, bg_;
108
bool
have_border_
;
109
bool
dirty_
;
110
};
111
112
}
gui::dialog_frame::top_right_
surface top_right_
Definition:
show_dialog.hpp:107
gui::dialog_manager::dialog_manager
dialog_manager()
Definition:
show_dialog.cpp:57
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:103
CVideo
Definition:
video.hpp:31
gui::in_dialog
bool in_dialog()
Definition:
show_dialog.cpp:52
draw_background
static void draw_background(surface screen, const SDL_Rect &area, const std::string &image)
Definition:
display.cpp:1481
surface_restorer
Definition:
surface.hpp:119
gui
General purpose widgets.
Definition:
tristate_button.cpp:29
gui::dialog_frame::buttons_
std::vector< button * > * buttons_
Definition:
show_dialog.hpp:102
cursor.hpp
gui::dialog_frame::restorer_
surface_restorer * restorer_
Definition:
show_dialog.hpp:104
surface
Definition:
surface.hpp:24
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:62
gui::dialog_frame::dialog_style_
const style & dialog_style_
Definition:
show_dialog.hpp:101
gui::ButtonHPadding
const int ButtonHPadding
Definition:
show_dialog.cpp:41
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:109
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:99
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::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:106
floating_label.hpp
w
int w
Definition:
function_table.cpp:136
gui::DIALOG_RESULT
DIALOG_RESULT
Definition:
show_dialog.hpp:30
gui::dialog_frame::video_
CVideo & video_
Definition:
show_dialog.hpp:100
gui::dialog_frame::auto_restore_
bool auto_restore_
Definition:
show_dialog.hpp:105
gui::dialog_frame::set_layout
void set_layout(dimension_measurements &new_dim)
Definition:
show_dialog.hpp:76
gui::ESCAPE_DIALOG
Definition:
show_dialog.hpp:35
gui::dialog_frame::get_layout
dimension_measurements get_layout() const
Definition:
show_dialog.hpp:77
gui::dialog_frame::have_border_
bool have_border_
Definition:
show_dialog.hpp:108
gui::ButtonVPadding
const int ButtonVPadding
Definition:
show_dialog.cpp:42
gui::dialog_frame::style::panel
std::string panel
Definition:
show_dialog.hpp:60
gui::dialog_frame::style
Definition:
show_dialog.hpp:57
Generated by
1.8.13