From 34e2c6b14308d343e1334cbfece3fe09fcd0570e Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 31 Mar 2015 06:08:43 +0800 Subject: [PATCH] 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 --- source/gui/filebox.cpp | 20 ++++++++++++++++++++ source/gui/widgets/textbox.cpp | 6 +++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index 78a40a3f..094793cc 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -972,6 +972,7 @@ namespace nana const nana::char_t * filter; nana::string filter_holder; + nana::string default_extension; if(impl_->filters.size()) { for(auto & f : impl_->filters) @@ -989,6 +990,21 @@ namespace nana } filter_holder += fs; filter_holder += static_cast('\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(); } @@ -1001,6 +1017,10 @@ namespace nana ofn.lpstrFileTitle = nullptr; ofn.nMaxFileTitle = 0; 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))) return false; diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index aabb494e..840a1762 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -314,7 +314,7 @@ namespace drawerbase { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if (editor->line_wrapped(autl)) - editor->render(API::is_focus_window(handle())); + API::update_window(handle()); return *this; } @@ -389,7 +389,7 @@ namespace drawerbase { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if(editor && editor->select(yes)) - API::refresh_window(*this); + API::update_window(*this); } void textbox::copy() const @@ -407,7 +407,7 @@ namespace drawerbase { if(editor) { editor->paste(); - API::refresh_window(*this); + API::update_window(*this); } }