Merge branch 'hotfix-1.6.2' into develop-1.7

This commit is contained in:
Jinhao 2019-02-02 00:26:52 +08:00
commit 7f12b76e08
8 changed files with 112 additions and 94 deletions

View File

@ -104,6 +104,7 @@ namespace drawerbase
struct element_tag struct element_tag
{ {
checkbox * uiobj; checkbox * uiobj;
event_handle eh_clicked;
event_handle eh_checked; event_handle eh_checked;
event_handle eh_destroy; event_handle eh_destroy;
event_handle eh_keyboard; event_handle eh_keyboard;

View File

@ -92,6 +92,9 @@ namespace nana{
/// Determines whether a specified option is checked, it throws an out_of_range if !(pos < number of options) /// Determines whether a specified option is checked, it throws an out_of_range if !(pos < number of options)
bool option_checked(std::size_t pos) const; bool option_checked(std::size_t pos) const;
/// Change typeface of caption label ( does not effect child widgets )
void typeface( const nana::paint::font& font );
group& enable_format_caption(bool format); group& enable_format_caption(bool format);
group& collocate() noexcept; group& collocate() noexcept;

View File

@ -151,7 +151,13 @@ namespace nana
bool vertical() const; bool vertical() const;
void maximum(unsigned); void maximum(unsigned);
unsigned maximum() const; unsigned maximum() const;
void value(unsigned);
/** Set slider value
@param[in] v new value for slider.
v will be clipped to the range 0 to maximum
*/
void value(int );
unsigned value() const; unsigned value() const;
unsigned move_step(bool forward); ///< Increase or decrease the value of slider. unsigned move_step(bool forward); ///< Increase or decrease the value of slider.
unsigned adorn() const; unsigned adorn() const;

View File

@ -216,6 +216,7 @@ namespace nana{ namespace drawerbase
{ {
e.uiobj->radio(false); e.uiobj->radio(false);
e.uiobj->react(true); e.uiobj->react(true);
API::umake_event(e.eh_clicked);
API::umake_event(e.eh_checked); API::umake_event(e.eh_checked);
API::umake_event(e.eh_destroy); API::umake_event(e.eh_destroy);
API::umake_event(e.eh_keyboard); API::umake_event(e.eh_keyboard);
@ -232,7 +233,7 @@ namespace nana{ namespace drawerbase
el.uiobj = &uiobj; el.uiobj = &uiobj;
uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg) el.eh_checked = uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg)
{ {
if (arg.widget->checked()) if (arg.widget->checked())
{ {
@ -244,7 +245,7 @@ namespace nana{ namespace drawerbase
} }
}, true); }, true);
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg) el.eh_clicked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
{ {
for (auto & i : ui_container_) for (auto & i : ui_container_)
i.uiobj->check(arg.window_handle == i.uiobj->handle()); i.uiobj->check(arg.window_handle == i.uiobj->handle());

View File

@ -27,10 +27,11 @@
if(empty()) \ if(empty()) \
throw std::logic_error("the group is invalid"); throw std::logic_error("the group is invalid");
namespace nana{ namespace nana
{
static const char* field_title = "__nana_group_title__"; static const char* field_title = "__nana_group_title__";
static const char* field_options = "__nana_group_options__"; static const char* field_options = "__nana_group_options__";
struct group::implement struct group::implement
{ {
@ -102,47 +103,48 @@ namespace nana{
if (caption.caption().empty()) if (caption.caption().empty())
place_content.field_display(field_title, false); place_content.field_display(field_title, false);
} }
}; };
group::group() group::group()
: impl_(new implement) : impl_(new implement)
{ {
} }
group::group(window parent, const rectangle& r, bool vsb) group::group(window parent, const rectangle& r, bool vsb)
: group() : group()
{ {
create(parent, r, vsb); create(parent, r, vsb);
} }
using groupbase_type = widget_object<category::widget_tag, drawerbase::panel::drawer, general_events, drawerbase::group::scheme>; using groupbase_type = widget_object<category::widget_tag, drawerbase::panel::drawer, general_events, drawerbase::group::scheme>;
group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb) group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb)
: group(parent, r, vsb) : group(parent, r, vsb)
{ {
this->bgcolor(API::bgcolor(parent)); this->bgcolor(API::bgcolor(parent));
impl_.reset(new implement(*this, std::move(titel), vsb, gap)); impl_.reset(new implement(*this, std::move(titel), vsb, gap));
impl_->caption.format(formatted); impl_->caption.format(formatted);
_m_init(); _m_init();
} }
group::~group() group::~group()
{ {
delete impl_->radio_logic; delete impl_->radio_logic;
} }
checkbox& group::add_option(std::string text) checkbox& group::add_option(std::string text)
{ {
_THROW_IF_EMPTY() _THROW_IF_EMPTY()
#ifdef _nana_std_has_emplace_return_type #ifdef _nana_std_has_emplace_return_type
auto & opt = impl_->options.emplace_back(new checkbox{ handle() }); auto & opt = impl_->options.emplace_back(new checkbox { handle() });
#else #else
impl_->options.emplace_back(new checkbox(handle())); impl_->options.emplace_back(new checkbox(handle()));
auto & opt = impl_->options.back(); auto & opt = impl_->options.back();
#endif #endif
opt->transparent(true); opt->transparent(true);
opt->caption(std::move(text)); opt->caption(std::move(text));
impl_->place_content[field_options] << *opt; impl_->place_content[field_options] << *opt;
@ -358,5 +360,6 @@ namespace nana{
impl_->update_div(); impl_->update_div();
impl_->place_content.collocate(); impl_->place_content.collocate();
} }
}//end namespace nana }//end namespace nana

View File

@ -1,7 +1,7 @@
/* /*
* A text editor implementation * A text editor implementation
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -1728,7 +1728,7 @@ namespace nana {
str = impl_->textbase.getline(0); str = impl_->textbase.getline(0);
for (std::size_t i = 1; i < lines; ++i) for (std::size_t i = 1; i < lines; ++i)
{ {
str += L"\n\r"; str += L"\r\n";
str += impl_->textbase.getline(i); str += impl_->textbase.getline(i);
} }
} }

View File

@ -844,10 +844,14 @@ namespace nana
return get_drawer_trigger().get_model()->attribute().vmax; return get_drawer_trigger().get_model()->attribute().vmax;
} }
void slider::value(unsigned v) void slider::value(int v)
{ {
if(handle()) if(handle())
{ {
// limit to positive values, vcur expects unsigned
if( v < 0 )
v = 0;
if(get_drawer_trigger().get_model()->vcur(v)) if(get_drawer_trigger().get_model()->vcur(v))
API::refresh_window(handle()); API::refresh_window(handle());
} }

View File

@ -467,7 +467,7 @@ namespace nana
std::wstring text; std::wstring text;
if (API::is_focus_ready(editor_->window_handle())) if (API::is_focus_ready(editor_->window_handle()) && editor_->attr().editable)
text = to_wstring(range_->value()); text = to_wstring(range_->value());
else else
text = to_wstring(modifier_.prefix + range_->value() + modifier_.suffix); text = to_wstring(modifier_.prefix + range_->value() + modifier_.suffix);