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