file_chooser.hpp

Go to the documentation of this file.
00001 /* $Id: file_chooser.hpp 23842 2008-02-16 08:47:16Z mordante $ */
00002 /*
00003    Copyright (C) 2003 - 2008 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 version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 #ifndef FILE_CHOOSER_H_INCLUDED
00015 #define FILE_CHOOSER_H_INCLUDED
00016 
00017 class config;
00018 class display;
00019 
00020 #include "construct_dialog.hpp"
00021 
00022 namespace gui
00023 {
00024     class file_menu;
00025 }
00026 
00027 namespace dialogs
00028 {
00029 
00030 class file_dialog : public gui::dialog {
00031 public:
00032     file_dialog(display &disp, const std::string& file_path, const std::string& title);
00033 
00034     virtual gui::dialog::dimension_measurements layout(int xloc=-1, int yloc=-1);
00035 
00036     /// Return the chosen file.
00037     std::string get_choice() const { return chosen_file_; }
00038 
00039 protected:
00040     void action(gui::dialog_process_info &dp_info);
00041     const std::string unformat_filename(const std::string& filename) const;
00042     const std::string format_filename(const std::string& filename) const;
00043     const std::string format_dirname(const std::string& dirname) const;
00044 
00045 private:
00046     gui::file_menu *files_list_;
00047     int last_selection_;
00048     std::string last_textbox_text_;
00049     std::string chosen_file_;
00050 };
00051 
00052 /// Show a dialog where the user can navigate through files and select a
00053 /// file. The filename is used as a starting point in the navigation and
00054 /// contains the chosen file when the function returns.  Return the
00055 /// index of the button pressed, or -1 if the dialog was canceled
00056 /// through keypress.
00057 int show_file_chooser_dialog(display &displ, std::string &filename,
00058                              std::string const &title, int xloc = -1, int yloc = -1);
00059 
00060 } // end of dialogs namespace
00061 
00062 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs