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