1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef _STUB_FILECHOOSER_H_
#define _STUB_FILECHOOSER_H_
#include "stub_mforms.h"
#include "stub_view.h"
#define RESPONSE_OK 1
#define RESPONSE_CANCEL 0
namespace mforms {
namespace stub {
class FileChooserWrapper : public ViewWrapper
{
static std::vector<std::string> split_string(const std::string &s, const std::string &sep)
{
std::vector<std::string> parts;
std::string ss= s;
std::string::size_type p;
if (s.empty())
return parts;
p= ss.find(sep);
while (!ss.empty() && p != std::string::npos)
{
parts.push_back(ss.substr(0, p));
ss= ss.substr(p+sep.size());
p= ss.find(sep);
}
parts.push_back(ss);
return parts;
}
static bool create(FileChooser *self, mforms::Form *owner, FileChooserType type, bool show_hidden)
{
return true;
}
static void set_title(::mforms::FileChooser *self, const std::string &title)
{
}
static bool show_modal(::mforms::FileChooser *self)
{
return true;
}
static void set_directory(FileChooser *self, const std::string &path)
{
}
static std::string get_directory(FileChooser *self)
{
return "";
}
static std::string get_path(FileChooser *self)
{
return "";
}
static void set_extensions(FileChooser *self, const std::string &extensions, const std::string &default_extension, bool allow_all_file_types = true)
{
}
//static bool create(FileChooser *self, FileChooserType type, bool show_hidden)
//{
// return true;
//}
FileChooserWrapper(::mforms::FileChooser *form, ::mforms::FileChooserType type)
: ViewWrapper(form)
{
}
virtual ~FileChooserWrapper()
{
}
public:
static void init()
{
::mforms::ControlFactory *f = ::mforms::ControlFactory::get_instance();
//TODO: Investigate how this should be addressed
//f->_filechooser_impl.create = &FileChooserWrapper::create;
f->_filechooser_impl.set_title = &FileChooserWrapper::set_title;
f->_filechooser_impl.run_modal = &FileChooserWrapper::show_modal;
f->_filechooser_impl.set_extensions = &FileChooserWrapper::set_extensions;
f->_filechooser_impl.set_directory = &FileChooserWrapper::set_directory;
f->_filechooser_impl.get_directory = &FileChooserWrapper::get_directory;
f->_filechooser_impl.get_path = &FileChooserWrapper::get_path;
f->_filechooser_impl.create = &FileChooserWrapper::create;
}
};
};
};
#endif
|