17 #define GETTEXT_DOMAIN "wesnoth-lib"
33 #define ERR_DP LOG_STREAM(err, log_display)
34 #define ERR_G LOG_STREAM(err, lg::general)
71 SDL_GetMouseState(&mousex, &mousey);
73 pb_event.type = SDL_MOUSEMOTION;
74 pb_event.motion.state = 0;
75 pb_event.motion.x = mousex;
76 pb_event.motion.y = mousey;
77 pb_event.motion.xrel = 0;
78 pb_event.motion.yrel = 0;
79 SDL_PushEvent(&pb_event);
84 std::vector<button*>* buttons,
button* help_button) :
89 help_button_(help_button),
91 auto_restore_(auto_restore),
94 top_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-top.png")),
95 bot_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-bottom.png")),
96 left_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-left.png")),
97 right_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-right.png")),
98 top_left_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-topleft.png")),
99 bot_left_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-botleft.png")),
100 top_right_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-topright.png")),
101 bot_right_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-border-botright.png")),
102 bg_(
image::get_texture(
"dialogs/" + dialog_style_.panel +
"-background.png")),
103 have_border_(!top_.null() && !bot_.null() && !
left_.null() && !
right_.null())
105 top_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-top.png")),
106 bot_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-bottom.png")),
109 top_left_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-topleft.png")),
110 bot_left_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-botleft.png")),
111 top_right_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-topright.png")),
112 bot_right_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-border-botright.png")),
113 bg_(
image::
get_image(
"dialogs/" + dialog_style_.panel +
"-background.png")),
114 have_border_(top_ != nullptr && bot_ != nullptr &&
left_ != nullptr &&
right_ != nullptr),
130 return layout(rect.x, rect.y, rect.w, rect.h);
137 padding +=
top_.height();
154 if (event.type == SDL_WINDOWEVENT) {
155 switch (event.window.event) {
156 case SDL_WINDOWEVENT_RESIZED:
157 case SDL_WINDOWEVENT_RESTORED:
158 case SDL_WINDOWEVENT_SHOWN:
159 case SDL_WINDOWEVENT_EXPOSED:
172 (*it)->set_dirty(
true);
185 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
186 padding = std::max<int>((**b).height() +
ButtonVPadding, padding);
191 padding +=
bot_.height();
206 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
232 bounds.x +=
left_.width();
233 bounds.y +=
top_.height();
234 bounds.w -=
left_.width();
235 bounds.h -=
top_.height();
237 bounds.x +=
left_->w;
239 bounds.w -=
left_->w;
253 }
else if(x + w > bounds.w) {
258 }
else if(y + h > bounds.h) {
315 if(top_image !=
nullptr) {
321 if(bot_image !=
nullptr) {
327 if(left_image !=
nullptr) {
333 if(right_image !=
nullptr) {
376 SDL_Rect
src = {0,0,0,0};
393 SDL_Rect
src = {0,0,0,0};
431 #ifdef OK_BUTTON_ON_RIGHT
434 for(std::vector<button*>::const_iterator
b =
buttons_->begin();
b !=
buttons_->end(); ++
b) {
435 (**b).set_location(buttons_area.x, buttons_area.y);
450 const std::vector<std::string>* menu_items,
451 const std::vector<preview_pane*>* preview_panes,
454 const int text_widget_max_chars,
455 std::vector<check_item>*
options,
459 std::vector<dialog_button_info>* action_buttons,
464 if (image.
null()) title = caption;
477 for(
unsigned int i=0;
i < preview_panes->size(); ++
i) {
481 if(text_widget_text) {
482 d.
set_textbox(text_widget_label,*text_widget_text, text_widget_max_chars);
485 for(
unsigned int i=0;
i < options->size(); ++
i) {
491 for(
unsigned int i=0;
i < action_buttons->size(); ++
i) {
500 for(
unsigned int i=0;
i < options->size(); ++
i)
505 if(text_widget_text) {
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
static const style preview_style
const SDL_Color TITLE_COLOR
void add_option(const std::string &label, bool checked=false, BUTTON_LOCATION loc=BUTTON_CHECKBOX, const std::string &help_string="")
void set_textbox(dialog_textbox *const box)
static const style default_style
void set_dirty(bool dirty=true)
GLuint GLuint GLsizei GLenum type
const SDL_Rect empty_rect
static const style & default_style
void add_button(dialog_button *const btn, BUTTON_LOCATION loc)
bool is_in_dialog()
Is a dialog open?
std::vector< button * > * buttons_
surface_restorer * restorer_
GLint GLint GLint GLint GLint GLint y
surface scale_surface(const surface &surf, int w, int h)
void blit_surface(int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr)
int show(int xloc, int yloc)
surface get_surface_portion(const surface &src, SDL_Rect &area)
Get a portion of the screen.
std::string textbox_text() const
const style & dialog_style_
GLdouble GLdouble GLdouble b
dimension_measurements layout(int x, int y, int w, int h)
SDL_Rect draw_title(CVideo *video)
int bottom_padding() const
void add_pane(preview_pane *const pp)
GLubyte GLubyte GLubyte GLubyte w
void set_menu(menu *const m)
virtual void handle_event(const SDL_Event &)
int show_dialog(CVideo &video, surface image, const std::string &caption, const std::string &message, DIALOG_TYPE type, const std::vector< std::string > *menu_items, const std::vector< preview_pane * > *preview_panes, const std::string &text_widget_label, std::string *text_widget_text, const int text_widget_max_chars, std::vector< check_item > *options, int xloc, int yloc, const dialog_frame::style *dialog_style, std::vector< dialog_button_info > *action_buttons, const menu::sorter *sorter, menu::style *menu_style)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
surface blur_surface(const surface &surf, int depth, bool optimize)
Cross-fades a surface.
int get_max_height(int size)
void set_image(dialog_image *const img)
SDL_Rect draw_text(surface &dst, const SDL_Rect &area, int size, const SDL_Color &color, const std::string &txt, int x, int y, bool use_tooltips, int style)
Function to draw text on a surface.
static const int title_border_w
static lg::log_domain log_display("display")
static const style titlescreen_style
dimension_measurements dim_
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint x
void handle_window_event(const SDL_Event &event)
bool option_checked(unsigned int option_index=0)
Contains the SDL_Rect helper code.
static const int max_menu_width
this module manages the cache of images.
Standard logging facilities (interface).
GLsizei GLenum GLuint GLuint GLsizei char * message
static const int title_border_h
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
dialog_frame(CVideo &video, const std::string &title="", const style &dialog_style=default_style, bool auto_restore=true, std::vector< button * > *buttons=nullptr, button *help_button=nullptr)
void update_rect(const SDL_Rect &)
GLsizei const GLcharARB ** string
static const style message_style