A widget where the user may navigate through directories and choose a file. More...
#include <file_menu.hpp>


Public Member Functions | |
| file_menu (CVideo &disp, std::string start_file="") | |
| Initialize the file menu. | |
| std::string | get_choice () const |
| Return the chosen file. | |
| int | delete_chosen_file () |
| std::string | get_directory () const |
| std::string | add_path (const std::string &path, const std::string &to_add) const |
| Return path with to_add added, using a path delimiter between them. | |
| std::string | strip_last_delim (const std::string &path) const |
| Return the string with the last path delimiter removed, if one was there. | |
| bool | is_directory (const std::string &fname) const |
| void | change_directory (const std::string &path) |
| bool | make_directory (const std::string &subdir_name) |
| void | select_file (const std::string &begin_of_filename) |
| Selects file (type-a-head search). | |
| bool | type_a_head () const |
| void | reset_type_a_head () |
Static Public Attributes | |
| static const char | path_delim |
Protected Member Functions | |
| void | handle_event (const SDL_Event &event) |
Private Member Functions | |
| std::string | get_path (const std::string &file_or_dir) const |
| If file_or_dir is a file, return the directory the file is in, if it is a directory, return the directory name. | |
| std::string | get_path_up (const std::string &path, const unsigned levels=1) const |
| Return the path that is the specified number of levels up from the path. | |
| bool | is_root (const std::string &path) const |
| Return true if the path is the root of the filesystem. | |
| void | display_current_files () |
| Show the files in the current directory. | |
| void | update_file_lists () |
| Updated the locally maintained lists of files and directories in the current directory. | |
| void | entry_selected (const unsigned entry) |
| Set the textbox to reflect the selected file. | |
Private Attributes | |
| std::string | current_dir_ |
| std::string | chosen_file_ |
| std::vector< std::string > | files_in_current_dir_ |
| std::vector< std::string > | dirs_in_current_dir_ |
| int | last_selection_ |
| int | type_a_head_ |
A widget where the user may navigate through directories and choose a file.
Definition at line 26 of file file_menu.hpp.
| gui::file_menu::file_menu | ( | CVideo & | disp, | |
| std::string | start_file = "" | |||
| ) |
Initialize the file menu.
start_file is the file that will be selected initially. The current directory will be the one the file is in.
Definition at line 36 of file file_menu.cpp.
References chosen_file_, current_dir_, file_exists(), is_directory(), path_delim, and update_file_lists().

| std::string gui::file_menu::add_path | ( | const std::string & | path, | |
| const std::string & | to_add | |||
| ) | const |
Return path with to_add added, using a path delimiter between them.
Definition at line 234 of file file_menu.cpp.
References get_path_up(), path_delim, gui::path_up(), and strip_last_delim().
Referenced by entry_selected(), and make_directory().


| void gui::file_menu::change_directory | ( | const std::string & | path | ) |
Definition at line 151 of file file_menu.cpp.
References chosen_file_, current_dir_, get_path_up(), is_root(), last_selection_, gui::path_up(), and update_file_lists().

| int gui::file_menu::delete_chosen_file | ( | ) |
Definition at line 86 of file file_menu.cpp.
References chosen_file_, current_dir_, last_selection_, and update_file_lists().

| void gui::file_menu::display_current_files | ( | ) | [private] |
Show the files in the current directory.
Definition at line 56 of file file_menu.cpp.
References COLUMN_SEPARATOR, current_dir_, gui::dir_picture(), dirs_in_current_dir_, files_in_current_dir_, font::IMAGE, is_root(), font::line_width(), gui::path_up(), gui::menu::set_items(), font::SIZE_NORMAL, and gui::widget::width().
Referenced by update_file_lists().


| void gui::file_menu::entry_selected | ( | const unsigned | entry | ) | [private] |
Set the textbox to reflect the selected file.
Definition at line 123 of file file_menu.cpp.
References add_path(), chosen_file_, current_dir_, dirs_in_current_dir_, files_in_current_dir_, is_root(), and game_config::images::selected.
Referenced by handle_event(), and reset_type_a_head().


| std::string gui::file_menu::get_choice | ( | ) | const |
| std::string gui::file_menu::get_directory | ( | ) | const [inline] |
Definition at line 41 of file file_menu.hpp.
References current_dir_.
| std::string gui::file_menu::get_path | ( | const std::string & | file_or_dir | ) | const [private] |
If file_or_dir is a file, return the directory the file is in, if it is a directory, return the directory name.
If no path delimiters could be found, return the unchanged argument.
Definition at line 178 of file file_menu.cpp.
References is_directory(), and path_delim.
Referenced by get_path_up().


| std::string gui::file_menu::get_path_up | ( | const std::string & | path, | |
| const unsigned | levels = 1 | |||
| ) | const [private] |
Return the path that is the specified number of levels up from the path.
If the movement could not proceed due to being at the root or having an invalid argument, return the path that the movement ended on.
Definition at line 189 of file file_menu.cpp.
References get_path(), is_root(), path_delim, and strip_last_delim().
Referenced by add_path(), and change_directory().


| void gui::file_menu::handle_event | ( | const SDL_Event & | event | ) | [protected, virtual] |
Reimplemented from gui::menu.
Definition at line 112 of file file_menu.cpp.
References entry_selected(), last_selection_, gui::menu::selection(), type_a_head(), and type_a_head_.

| bool gui::file_menu::is_directory | ( | const std::string & | fname | ) | const |
Definition at line 145 of file file_menu.cpp.
References gui::path_up().
Referenced by file_menu(), and get_path().


| bool gui::file_menu::is_root | ( | const std::string & | path | ) | const [private] |
Return true if the path is the root of the filesystem.
Definition at line 226 of file file_menu.cpp.
References path_delim.
Referenced by change_directory(), display_current_files(), entry_selected(), get_path_up(), and select_file().

| bool gui::file_menu::make_directory | ( | const std::string & | subdir_name | ) |
Definition at line 99 of file file_menu.cpp.
References add_path(), chosen_file_, current_dir_, last_selection_, and update_file_lists().

| void gui::file_menu::reset_type_a_head | ( | ) |
Definition at line 283 of file file_menu.cpp.
References entry_selected(), last_selection_, and type_a_head_.

| void gui::file_menu::select_file | ( | const std::string & | begin_of_filename | ) |
Selects file (type-a-head search).
Definition at line 293 of file file_menu.cpp.
References current_dir_, dirs_in_current_dir_, files_in_current_dir_, is_root(), gui::menu::move_selection(), and type_a_head_.

| std::string gui::file_menu::strip_last_delim | ( | const std::string & | path | ) | const |
Return the string with the last path delimiter removed, if one was there.
Definition at line 218 of file file_menu.cpp.
References path_delim.
Referenced by add_path(), and get_path_up().

| bool gui::file_menu::type_a_head | ( | ) | const |
Definition at line 278 of file file_menu.cpp.
References gui::menu::selection(), and type_a_head_.
Referenced by handle_event().


| void gui::file_menu::update_file_lists | ( | ) | [private] |
Updated the locally maintained lists of files and directories in the current directory.
Definition at line 315 of file file_menu.cpp.
References current_dir_, dirs_in_current_dir_, display_current_files(), FILE_NAME_ONLY, files_in_current_dir_, and get_files_in_dir().
Referenced by change_directory(), delete_chosen_file(), file_menu(), and make_directory().


std::string gui::file_menu::chosen_file_ [private] |
Definition at line 94 of file file_menu.hpp.
Referenced by change_directory(), delete_chosen_file(), entry_selected(), file_menu(), get_choice(), and make_directory().
std::string gui::file_menu::current_dir_ [private] |
Definition at line 93 of file file_menu.hpp.
Referenced by change_directory(), delete_chosen_file(), display_current_files(), entry_selected(), file_menu(), get_directory(), make_directory(), select_file(), and update_file_lists().
std::vector<std::string> gui::file_menu::dirs_in_current_dir_ [private] |
Definition at line 95 of file file_menu.hpp.
Referenced by display_current_files(), entry_selected(), select_file(), and update_file_lists().
std::vector<std::string> gui::file_menu::files_in_current_dir_ [private] |
Definition at line 95 of file file_menu.hpp.
Referenced by display_current_files(), entry_selected(), select_file(), and update_file_lists().
int gui::file_menu::last_selection_ [private] |
Definition at line 96 of file file_menu.hpp.
Referenced by change_directory(), delete_chosen_file(), handle_event(), make_directory(), and reset_type_a_head().
const char gui::file_menu::path_delim [static] |
Definition at line 29 of file file_menu.hpp.
Referenced by add_path(), file_menu(), get_path(), get_path_up(), is_root(), and strip_last_delim().
int gui::file_menu::type_a_head_ [private] |
Definition at line 97 of file file_menu.hpp.
Referenced by handle_event(), reset_type_a_head(), select_file(), and type_a_head().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:21:18 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |