The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
filechooser.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
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 #ifndef FILE_CHOOSER_H_INCLUDED
15 #define FILE_CHOOSER_H_INCLUDED
16 
17 class config;
18 class CVideo;
19 
20 #include "construct_dialog.hpp"
21 
22 namespace gui
23 {
24  class file_menu;
25 }
26 
27 namespace dialogs
28 {
29 
30 class file_dialog : public gui::dialog {
31 public:
32  file_dialog(CVideo& video, const std::string& file_path, const std::string& title, const std::string& default_file_name, bool show_directory_buttons);
33 
34  virtual gui::dialog::dimension_measurements layout(int xloc=-1, int yloc=-1);
35 
36  /// Return the chosen file.
37  std::string get_choice() const { return chosen_file_; }
38 
39  void select_file(const std::string& file);
40 
42 
43 protected:
44  void action(gui::dialog_process_info &dp_info);
45  void set_save_text(const std::string& filename);
46  std::string unformat_filename(const std::string& filename) const;
47  std::string format_filename(const std::string& filename) const;
48  std::string format_dirname(const std::string& dirname) const;
49 
50 private:
58 };
59 
60 /// Show a dialog where the user can navigate through files and select a
61 /// file. The filename is used as a starting point in the navigation and
62 /// contains the chosen file when the function returns. Return the
63 /// index of the button pressed, or -1 if the dialog was canceled
64 /// through keypress.
65 int show_file_chooser_dialog(CVideo& video, std::string &filename,
66  std::string const &title, bool show_directory_buttons = true,
67  const std::string& file_to_search = "",
68  int xloc = -1, int yloc = -1);
69 
70 /// Show a filechooser dialog in a "save" mode, that is, without relying
71 /// on autocomplete to allow saving under any filename
73  std::string const &title,
74  const std::string& default_file_name = "",
75  bool show_directory_buttons = true,
76  const std::string& file_to_search = "",
77  int xloc = -1, int yloc = -1);
78 } // end of dialogs namespace
79 
80 #endif
int show_file_chooser_dialog_save(CVideo &video, std::string &filename, std::string const &title, const std::string &default_file_name, bool show_directory_buttons, const std::string &type_a_head, int xloc, int yloc)
Show a filechooser dialog in a "save" mode, that is, without relying on autocomplete to allow saving ...
Definition: filechooser.cpp:44
void set_autocomplete(bool value)
Definition: filechooser.hpp:41
void set_save_text(const std::string &filename)
Definition: video.hpp:58
std::string get_choice() const
Return the chosen file.
Definition: filechooser.hpp:37
General purpose widgets.
std::string format_filename(const std::string &filename) const
std::string chosen_file_
Definition: filechooser.hpp:55
GLsizei const GLfloat * value
Definition: glew.h:1817
virtual gui::dialog::dimension_measurements layout(int xloc=-1, int yloc=-1)
Definition: filechooser.cpp:90
int show_file_chooser_dialog(CVideo &video, std::string &filename, std::string const &title, bool show_directory_buttons, const std::string &type_a_head, int xloc, int yloc)
Show a dialog where the user can navigate through files and select a file.
Definition: filechooser.cpp:30
void select_file(const std::string &file)
Various uncategorised dialogs.
Definition: dialogs.cpp:85
void action(gui::dialog_process_info &dp_info)
std::string last_textbox_text_
Definition: filechooser.hpp:54
file_dialog(CVideo &video, const std::string &file_path, const std::string &title, const std::string &default_file_name, bool show_directory_buttons)
Definition: filechooser.cpp:61
std::string unformat_filename(const std::string &filename) const
gui::file_menu * files_list_
Definition: filechooser.hpp:52
std::string default_file_name_
Definition: filechooser.hpp:56
A widget where the user may navigate through directories and choose a file.
Definition: file_menu.hpp:25
std::string format_dirname(const std::string &dirname) const
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503