filechooser.hpp

Go to the documentation of this file.
00001 /* $Id: filechooser.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #ifndef FILE_CHOOSER_H_INCLUDED
00016 #define FILE_CHOOSER_H_INCLUDED
00017 
00018 class config;
00019 class display;
00020 
00021 #include "construct_dialog.hpp"
00022 
00023 namespace gui
00024 {
00025     class file_menu;
00026 }
00027 
00028 namespace dialogs
00029 {
00030 
00031 class file_dialog : public gui::dialog {
00032 public:
00033     file_dialog(display &disp, const std::string& file_path, const std::string& title, bool show_directory_buttons);
00034 
00035     virtual gui::dialog::dimension_measurements layout(int xloc=-1, int yloc=-1);
00036 
00037     /// Return the chosen file.
00038     std::string get_choice() const { return chosen_file_; }
00039 
00040     void select_file(const std::string& file);
00041 
00042     void set_autocomplete(bool value) { autocomplete_ = value; }
00043 
00044 protected:
00045     void action(gui::dialog_process_info &dp_info);
00046     std::string unformat_filename(const std::string& filename) const;
00047     std::string format_filename(const std::string& filename) const;
00048     std::string format_dirname(const std::string& dirname) const;
00049 
00050 private:
00051     bool show_directory_buttons_;
00052     gui::file_menu *files_list_;
00053     int last_selection_;
00054     std::string last_textbox_text_;
00055     std::string chosen_file_;
00056     bool autocomplete_;
00057 };
00058 
00059 /// Show a dialog where the user can navigate through files and select a
00060 /// file. The filename is used as a starting point in the navigation and
00061 /// contains the chosen file when the function returns.  Return the
00062 /// index of the button pressed, or -1 if the dialog was canceled
00063 /// through keypress.
00064 int show_file_chooser_dialog(display &displ, std::string &filename,
00065                              std::string const &title, bool show_directory_buttons = true,
00066                              const std::string& file_to_search = "",
00067                              int xloc = -1, int yloc = -1);
00068 
00069 /// Show a filechooser dialog in a "save" mode, that is, without relying
00070 /// on autocomplete to allow saving under any filename
00071 int show_file_chooser_dialog_save(display &displ, std::string &filename,
00072                              std::string const &title, bool show_directory_buttons = true,
00073                              const std::string& file_to_search = "",
00074                              int xloc = -1, int yloc = -1);
00075 } // end of dialogs namespace
00076 
00077 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:36 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs