The Battle for Wesnoth  1.15.1+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 http://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;
35  ESCAPE_DIALOG=-3, //special return used by WML event dialogs
38  /* results (0..N) reserved for standard button indices */
39 };
40 
41 bool in_dialog();
42 
46 
47 private:
48  bool reset_to;
49 };
50 
52 public:
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;
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_;
105  std::vector<button*>* buttons_;
110  surface top_, bot_, left_, right_, top_left_, bot_left_, top_right_, bot_right_, bg_;
112  bool dirty_;
113 };
114 
115 }
static const style preview_style
Definition: show_dialog.hpp:68
static const style default_style
Definition: show_dialog.hpp:66
Definition: video.hpp:31
bool in_dialog()
Definition: show_dialog.cpp:56
static void draw_background(surface screen, const SDL_Rect &area, const std::string &image)
Definition: display.cpp:1464
General purpose widgets.
std::vector< button * > * buttons_
surface_restorer * restorer_
#define h
-file util.hpp
const style & dialog_style_
const int ButtonHPadding
Definition: show_dialog.cpp:42
std::string title_
style(const std::string &p, int br)
Definition: show_dialog.hpp:59
static const int title_border_w
Definition: show_dialog.hpp:65
static const style titlescreen_style
Definition: show_dialog.hpp:69
mock_party p
structure which will hide all current floating labels, and cause floating labels instantiated after i...
dimension_measurements dim_
int w
DIALOG_RESULT
Definition: show_dialog.hpp:30
void set_layout(dimension_measurements &new_dim)
Definition: show_dialog.hpp:79
dimension_measurements get_layout() const
Definition: show_dialog.hpp:80
const int ButtonVPadding
Definition: show_dialog.cpp:43
static const style message_style
Definition: show_dialog.hpp:67