fix issues of textbox and filebox

no refresh when calling textbox line_wrapped
add filebox overwrite prompt for saving file
the first non-* filter to be set default extentsion for filebox
This commit is contained in:
Jinhao 2015-03-31 06:08:43 +08:00
parent dcead38544
commit 34e2c6b143
2 changed files with 23 additions and 3 deletions

View File

@ -972,6 +972,7 @@ namespace nana
const nana::char_t * filter; const nana::char_t * filter;
nana::string filter_holder; nana::string filter_holder;
nana::string default_extension;
if(impl_->filters.size()) if(impl_->filters.size())
{ {
for(auto & f : impl_->filters) for(auto & f : impl_->filters)
@ -989,6 +990,21 @@ namespace nana
} }
filter_holder += fs; filter_holder += fs;
filter_holder += static_cast<nana::string::value_type>('\0'); filter_holder += static_cast<nana::string::value_type>('\0');
//Get the default file extentsion
if (default_extension.empty())
{
pos = fs.find_last_of('.');
if (pos != fs.npos)
{
fs = fs.substr(pos + 1);
if (fs != L"*")
{
default_extension = fs;
ofn.lpstrDefExt = default_extension.data();
}
}
}
} }
filter = filter_holder.data(); filter = filter_holder.data();
} }
@ -1001,6 +1017,10 @@ namespace nana
ofn.lpstrFileTitle = nullptr; ofn.lpstrFileTitle = nullptr;
ofn.nMaxFileTitle = 0; ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = (impl_->path.size() ? impl_->path.c_str() : nullptr); ofn.lpstrInitialDir = (impl_->path.size() ? impl_->path.c_str() : nullptr);
if (!impl_->open_or_save)
ofn.Flags = OFN_OVERWRITEPROMPT; //Overwrite prompt if it is save mode
if(FALSE == (impl_->open_or_save ? ::GetOpenFileName(&ofn) : ::GetSaveFileName(&ofn))) if(FALSE == (impl_->open_or_save ? ::GetOpenFileName(&ofn) : ::GetSaveFileName(&ofn)))
return false; return false;

View File

@ -314,7 +314,7 @@ namespace drawerbase {
internal_scope_guard lock; internal_scope_guard lock;
auto editor = get_drawer_trigger().editor(); auto editor = get_drawer_trigger().editor();
if (editor->line_wrapped(autl)) if (editor->line_wrapped(autl))
editor->render(API::is_focus_window(handle())); API::update_window(handle());
return *this; return *this;
} }
@ -389,7 +389,7 @@ namespace drawerbase {
internal_scope_guard lock; internal_scope_guard lock;
auto editor = get_drawer_trigger().editor(); auto editor = get_drawer_trigger().editor();
if(editor && editor->select(yes)) if(editor && editor->select(yes))
API::refresh_window(*this); API::update_window(*this);
} }
void textbox::copy() const void textbox::copy() const
@ -407,7 +407,7 @@ namespace drawerbase {
if(editor) if(editor)
{ {
editor->paste(); editor->paste();
API::refresh_window(*this); API::update_window(*this);
} }
} }