Merge remote-tracking branch 'cnjinhao/develop' into develop
This commit is contained in:
commit
e1c1976e2f
@ -108,6 +108,7 @@ namespace nana
|
|||||||
virtual window create(window, unsigned label_px) = 0;
|
virtual window create(window, unsigned label_px) = 0;
|
||||||
virtual unsigned fixed_pixels() const;
|
virtual unsigned fixed_pixels() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class boolean
|
class boolean
|
||||||
: public abstract_content
|
: public abstract_content
|
||||||
@ -240,7 +241,6 @@ namespace nana
|
|||||||
{
|
{
|
||||||
std::vector<abstract_content*> contents;
|
std::vector<abstract_content*> contents;
|
||||||
_m_fetch_args(contents, std::forward<Args>(args)...);
|
_m_fetch_args(contents, std::forward<Args>(args)...);
|
||||||
|
|
||||||
if (contents.empty())
|
if (contents.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -261,6 +261,14 @@ namespace nana
|
|||||||
|
|
||||||
/// Sets a verifier to verify the user input.
|
/// Sets a verifier to verify the user input.
|
||||||
void verify(std::function<bool(window)> verifier);
|
void verify(std::function<bool(window)> verifier);
|
||||||
|
|
||||||
|
/** Sets the minimum width for the entry fields
|
||||||
|
@param[in] pixels new minimum width
|
||||||
|
|
||||||
|
If not called, the default is 100 pixels
|
||||||
|
*/
|
||||||
|
void min_width_entry_field( unsigned pixels );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _m_fetch_args(std::vector<abstract_content*>&);
|
void _m_fetch_args(std::vector<abstract_content*>&);
|
||||||
|
|
||||||
@ -279,6 +287,7 @@ namespace nana
|
|||||||
std::function<bool(window)> verifier_;
|
std::function<bool(window)> verifier_;
|
||||||
::nana::paint::image images_[4];
|
::nana::paint::image images_[4];
|
||||||
::nana::rectangle valid_areas_[4];
|
::nana::rectangle valid_areas_[4];
|
||||||
|
int min_width_entry_field_pixels_;
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#include <nana/pop_ignore_diagnostic>
|
#include <nana/pop_ignore_diagnostic>
|
||||||
|
@ -535,7 +535,7 @@ namespace nana
|
|||||||
throw std::invalid_argument("invalid listbox model container type");
|
throw std::invalid_argument("invalid listbox model container type");
|
||||||
|
|
||||||
if (nullptr == p->pointer())
|
if (nullptr == p->pointer())
|
||||||
throw std::runtime_error("the modal is immutable");
|
throw std::runtime_error("the modal is immutable, please declare model_guard with const");
|
||||||
|
|
||||||
return *static_cast<stlcontainer*>(p->pointer());
|
return *static_cast<stlcontainer*>(p->pointer());
|
||||||
}
|
}
|
||||||
@ -1254,8 +1254,9 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
listbox.anyobj(0, 0, 10); //the type of customer's object is int.
|
auto cat = listbox.at(0);
|
||||||
listbox.anyobj(0, 0, 20);
|
cat.at(0).value(10); //10 is custom data.
|
||||||
|
cat.at(1).value(20); //20 is custom data.
|
||||||
5. listbox is a widget_object, with template parameters drawerbase::listbox::trigger and drawerbase::listbox::scheme
|
5. listbox is a widget_object, with template parameters drawerbase::listbox::trigger and drawerbase::listbox::scheme
|
||||||
amon others.
|
amon others.
|
||||||
That means that listbox have a member trigger_ constructed first and accecible with get_drawer_trigger() and
|
That means that listbox have a member trigger_ constructed first and accecible with get_drawer_trigger() and
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A Progress Indicator Implementation
|
* A Progress Indicator Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2017 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
|
||||||
@ -20,42 +20,37 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace progress
|
namespace progress
|
||||||
{
|
{
|
||||||
class trigger: public drawer_trigger
|
struct scheme
|
||||||
|
: public widget_geometrics
|
||||||
|
{
|
||||||
|
scheme();
|
||||||
|
|
||||||
|
color_proxy gradient_bgcolor{ colors::button_face_shadow_start };
|
||||||
|
color_proxy gradient_fgcolor{ static_cast<color_rgb>(0x6FFFA8) };
|
||||||
|
};
|
||||||
|
|
||||||
|
class substance;
|
||||||
|
|
||||||
|
class trigger
|
||||||
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unsigned value() const;
|
trigger();
|
||||||
unsigned value(unsigned);
|
~trigger();
|
||||||
unsigned inc();
|
|
||||||
unsigned Max() const;
|
substance* progress() const;
|
||||||
unsigned Max(unsigned);
|
|
||||||
void unknown(bool);
|
|
||||||
bool unknown() const;
|
|
||||||
bool stop(bool s = true);
|
|
||||||
bool stopped() const;
|
|
||||||
private:
|
private:
|
||||||
void attached(widget_reference, graph_reference) override;
|
void attached(widget_reference, graph_reference) override;
|
||||||
void refresh(graph_reference) override;
|
void refresh(graph_reference) override;
|
||||||
private:
|
private:
|
||||||
void _m_draw_box(graph_reference);
|
substance* const progress_;
|
||||||
void _m_draw_progress(graph_reference);
|
};
|
||||||
bool _m_check_changing(unsigned) const;
|
|
||||||
private:
|
|
||||||
static const unsigned border = 2;
|
|
||||||
|
|
||||||
widget * widget_{nullptr};
|
|
||||||
nana::paint::graphics* graph_{nullptr};
|
|
||||||
unsigned draw_width_{static_cast<unsigned>(-1)};
|
|
||||||
bool unknown_{false};
|
|
||||||
bool stop_{false};
|
|
||||||
unsigned max_{100};
|
|
||||||
unsigned value_{0};
|
|
||||||
}; //end class drawer
|
|
||||||
}
|
}
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
/// \brief A progressbar widget with two styles: know, and unknow amount value (goal).
|
/// \brief A progressbar widget with two styles: know, and unknow amount value (goal).
|
||||||
/// In unknow style the amount is ignored and the bar is scrolled when value change.
|
/// In unknow style the amount is ignored and the bar is scrolled when value change.
|
||||||
class progress
|
class progress
|
||||||
: public widget_object<category::widget_tag, drawerbase::progress::trigger>
|
: public widget_object<category::widget_tag, drawerbase::progress::trigger, ::nana::general_events, drawerbase::progress::scheme>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
progress();
|
progress();
|
||||||
@ -69,8 +64,6 @@ namespace nana
|
|||||||
unsigned amount(unsigned value);
|
unsigned amount(unsigned value);
|
||||||
void unknown(bool);
|
void unknown(bool);
|
||||||
bool unknown() const;
|
bool unknown() const;
|
||||||
bool stop(bool s=true); ///< request stop or cancel and return previus stop status
|
|
||||||
bool stopped() const;
|
|
||||||
};
|
};
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
@ -114,8 +114,30 @@ namespace nana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* parent = wd->parent; parent; parent = parent->parent)
|
for (auto parent = wd->parent; parent; parent = parent->parent)
|
||||||
{
|
{
|
||||||
|
if (category::flags::root == parent->other.category)
|
||||||
|
{
|
||||||
|
//visual rectangle of wd's parent
|
||||||
|
rectangle vrt_parent{parent->pos_root, parent->dimension};
|
||||||
|
|
||||||
|
point pos_root;
|
||||||
|
while (parent->parent)
|
||||||
|
{
|
||||||
|
pos_root -= native_interface::window_position(parent->root);
|
||||||
|
|
||||||
|
if (!overlap(rectangle{ pos_root, parent->parent->root_widget->dimension }, vrt_parent, vrt_parent))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
parent = parent->parent->root_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!overlap(vrt_parent, visual, visual))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual))
|
if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -733,30 +733,6 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sync_child_root_display(window_manager::core_window_t* wd)
|
|
||||||
{
|
|
||||||
for (auto & child : wd->children)
|
|
||||||
{
|
|
||||||
if (category::flags::root != child->other.category)
|
|
||||||
{
|
|
||||||
sync_child_root_display(child);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto const vs_parents = child->visible_parents();
|
|
||||||
|
|
||||||
if (vs_parents != child->visible)
|
|
||||||
{
|
|
||||||
native_interface::show_window(child->root, vs_parents, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (child->visible != native_interface::is_window_visible(child->root))
|
|
||||||
native_interface::show_window(child->root, child->visible, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//show
|
//show
|
||||||
//@brief: show or hide a window
|
//@brief: show or hide a window
|
||||||
bool window_manager::show(core_window_t* wd, bool visible)
|
bool window_manager::show(core_window_t* wd, bool visible)
|
||||||
@ -792,15 +768,8 @@ namespace detail
|
|||||||
bedrock::instance().event_expose(wd, visible);
|
bedrock::instance().event_expose(wd, visible);
|
||||||
|
|
||||||
if (nv)
|
if (nv)
|
||||||
{
|
|
||||||
if (visible && !wd->visible_parents())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
native_interface::show_window(nv, visible, wd->flags.take_active);
|
native_interface::show_window(nv, visible, wd->flags.take_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
sync_child_root_display(wd);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: nana/gui/msgbox.hpp
|
* @file: nana/gui/msgbox.hpp
|
||||||
|
* @Contributors
|
||||||
|
* James Bremner
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/gui.hpp>
|
#include <nana/gui.hpp>
|
||||||
@ -1258,7 +1260,8 @@ namespace nana
|
|||||||
inputbox::inputbox(window owner, ::std::string desc, ::std::string title)
|
inputbox::inputbox(window owner, ::std::string desc, ::std::string title)
|
||||||
: owner_{ owner },
|
: owner_{ owner },
|
||||||
description_(std::move(desc)),
|
description_(std::move(desc)),
|
||||||
title_(std::move(title))
|
title_(std::move(title)),
|
||||||
|
min_width_entry_field_pixels_( 100 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void inputbox::image(::nana::paint::image img, bool is_left, const rectangle& valid_area)
|
void inputbox::image(::nana::paint::image img, bool is_left, const rectangle& valid_area)
|
||||||
@ -1280,6 +1283,17 @@ namespace nana
|
|||||||
verifier_ = std::move(verifier);
|
verifier_ = std::move(verifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Inputbox set minimum width entry field(https://github.com/cnjinhao/nana/pull/234)
|
||||||
|
//Contributed by James Bremner
|
||||||
|
void inputbox::min_width_entry_field( unsigned pixels )
|
||||||
|
{
|
||||||
|
// don't let the entry fields vanish entirely
|
||||||
|
if( pixels < 10 )
|
||||||
|
pixels = 10;
|
||||||
|
|
||||||
|
min_width_entry_field_pixels_ = pixels;
|
||||||
|
}
|
||||||
|
|
||||||
void inputbox::_m_fetch_args(std::vector<abstract_content*>&)
|
void inputbox::_m_fetch_args(std::vector<abstract_content*>&)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -1304,9 +1318,9 @@ namespace nana
|
|||||||
each_pixels.push_back(px.height);
|
each_pixels.push_back(px.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Adjust the fixed_px for good looking
|
//Ensure that the entry fields are at least as wide as the minimum
|
||||||
if (has_0_fixed_px && (fixed_px < 100))
|
if (has_0_fixed_px && (fixed_px < min_width_entry_field_pixels_ ))
|
||||||
fixed_px = 100;
|
fixed_px = min_width_entry_field_pixels_;
|
||||||
|
|
||||||
inputbox_window input_wd(owner_, images_, valid_areas_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
|
inputbox_window input_wd(owner_, images_, valid_areas_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ namespace nana
|
|||||||
|
|
||||||
auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
|
auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
|
||||||
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme);
|
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme);
|
||||||
|
_m_text_area(graph.size());
|
||||||
editor_->multi_lines(false);
|
editor_->multi_lines(false);
|
||||||
editable(false);
|
editable(false);
|
||||||
graph_ = &graph;
|
graph_ = &graph;
|
||||||
@ -177,21 +178,6 @@ namespace nana
|
|||||||
return any_ptr.get();
|
return any_ptr.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_area(const nana::size& s)
|
|
||||||
{
|
|
||||||
auto extension = measurer_->extension();
|
|
||||||
|
|
||||||
nana::rectangle r(2, 2, s.width > extension.width ? s.width - extension.width : 0, s.height > extension.height ? s.height - extension.height : 0);
|
|
||||||
if(image_enabled_)
|
|
||||||
{
|
|
||||||
unsigned place = image_pixels_ + 2;
|
|
||||||
r.x += place;
|
|
||||||
if(r.width > place) r.width -= place;
|
|
||||||
}
|
|
||||||
editor_->text_area(r);
|
|
||||||
editor_->render(state_.focused);
|
|
||||||
}
|
|
||||||
|
|
||||||
widgets::skeletons::text_editor * editor() const
|
widgets::skeletons::text_editor * editor() const
|
||||||
{
|
{
|
||||||
return editor_;
|
return editor_;
|
||||||
@ -364,12 +350,13 @@ namespace nana
|
|||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
bool enb = widget_->enabled();
|
bool enb = widget_->enabled();
|
||||||
if(editor_)
|
|
||||||
{
|
_m_text_area(widget_->size());
|
||||||
text_area(widget_->size());
|
editor_->render(state_.focused);
|
||||||
}
|
|
||||||
_m_draw_push_button(enb);
|
_m_draw_push_button(enb);
|
||||||
_m_draw_image();
|
_m_draw_image();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t the_number_of_options() const
|
std::size_t the_number_of_options() const
|
||||||
@ -496,6 +483,20 @@ namespace nana
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
void _m_text_area(const nana::size& s)
|
||||||
|
{
|
||||||
|
auto extension = measurer_->extension();
|
||||||
|
|
||||||
|
nana::rectangle r(2, 2, s.width > extension.width ? s.width - extension.width : 0, s.height > extension.height ? s.height - extension.height : 0);
|
||||||
|
if (image_enabled_)
|
||||||
|
{
|
||||||
|
unsigned place = image_pixels_ + 2;
|
||||||
|
r.x += place;
|
||||||
|
if (r.width > place) r.width -= place;
|
||||||
|
}
|
||||||
|
editor_->text_area(r);
|
||||||
|
}
|
||||||
|
|
||||||
void _m_draw_push_button(bool enabled)
|
void _m_draw_push_button(bool enabled)
|
||||||
{
|
{
|
||||||
::nana::rectangle r{graph_->size()};
|
::nana::rectangle r{graph_->size()};
|
||||||
|
@ -624,10 +624,14 @@ namespace nana
|
|||||||
}
|
}
|
||||||
else if (item_ptr->flags.enabled)
|
else if (item_ptr->flags.enabled)
|
||||||
{
|
{
|
||||||
|
//A pointer refers to a menu object which owns the menu window.
|
||||||
|
//After fn_close_tree_(), *this is an invalid object.
|
||||||
|
auto owner = menu_->owner;
|
||||||
|
|
||||||
fn_close_tree_();
|
fn_close_tree_();
|
||||||
if (item_ptr->event_handler)
|
if (item_ptr->event_handler)
|
||||||
{
|
{
|
||||||
item_proxy ip{ index, menu_->owner };
|
item_proxy ip{ index, owner };
|
||||||
item_ptr->event_handler.operator()(ip);
|
item_ptr->event_handler.operator()(ip);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -1019,13 +1023,18 @@ namespace nana
|
|||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (2 != send_shortkey(arg.key))
|
switch (send_shortkey(arg.key))
|
||||||
{
|
{
|
||||||
if (API::empty_window(*this) == false)
|
case 0:
|
||||||
|
if (this->empty() == false)
|
||||||
close();
|
close();
|
||||||
}
|
break;
|
||||||
else
|
case 1: //The menu has been closed
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
this->submenu(true);
|
this->submenu(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* A Progress Indicator Implementation
|
* A Progress Indicator Implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2017 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
|
||||||
@ -17,136 +17,187 @@ namespace nana
|
|||||||
{
|
{
|
||||||
namespace progress
|
namespace progress
|
||||||
{
|
{
|
||||||
//class trigger
|
scheme::scheme()
|
||||||
void trigger::attached(widget_reference wd, graph_reference graph)
|
|
||||||
{
|
{
|
||||||
widget_ = &wd;
|
foreground = static_cast<color_rgb>(0x107515);
|
||||||
graph_ = &graph;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned trigger::value() const
|
class substance
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
static const unsigned border_px = 1;
|
||||||
|
|
||||||
|
void set_widget(widget& wdg)
|
||||||
|
{
|
||||||
|
widget_ = static_cast<nana::progress*>(&wdg);
|
||||||
|
}
|
||||||
|
|
||||||
|
nana::progress* widget_ptr() const
|
||||||
|
{
|
||||||
|
return widget_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned inc()
|
||||||
|
{
|
||||||
|
auto val = value(nullptr) + 1;
|
||||||
|
return value(&val);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned value(const unsigned* value_ptr)
|
||||||
|
{
|
||||||
|
//Sets new value if value_ptr is not a nullptr
|
||||||
|
if (value_ptr)
|
||||||
|
{
|
||||||
|
if (unknown_)
|
||||||
|
value_ += (*value_ptr ? 5 : 0);
|
||||||
|
else
|
||||||
|
value_ = (std::min)(max_, *value_ptr);
|
||||||
|
|
||||||
|
_m_try_refresh();
|
||||||
|
}
|
||||||
return value_;
|
return value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned trigger::value(unsigned v)
|
void reset_value()
|
||||||
{
|
{
|
||||||
internal_scope_guard isg;
|
value_ = 0;
|
||||||
if(false == unknown_)
|
|
||||||
{
|
|
||||||
if(value_ != v)
|
|
||||||
value_ = v > max_?max_:v;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
value_ += (v?10:v);
|
|
||||||
|
|
||||||
if(_m_check_changing(value_))
|
|
||||||
{
|
|
||||||
refresh(*graph_);
|
|
||||||
API::update_window(widget_->handle());
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned trigger::inc()
|
unsigned maximum(const unsigned * value_ptr)
|
||||||
{
|
{
|
||||||
internal_scope_guard isg;
|
//Sets new maximum if value_ptr is not a nullptr
|
||||||
if(false == unknown_)
|
if (value_ptr)
|
||||||
{
|
{
|
||||||
if(value_ < max_)
|
max_ = (*value_ptr > 0 ? *value_ptr : 1);
|
||||||
++value_;
|
_m_try_refresh();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
value_ += 5;
|
|
||||||
|
|
||||||
if(_m_check_changing(value_))
|
|
||||||
API::refresh_window(widget_->handle());
|
|
||||||
return value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned trigger::Max() const
|
|
||||||
{
|
|
||||||
return max_;
|
return max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned trigger::Max(unsigned value)
|
bool unknown(const bool* state_ptr)
|
||||||
{
|
{
|
||||||
max_ = value;
|
if (state_ptr)
|
||||||
if(max_ == 0) ++max_;
|
{
|
||||||
|
unknown_ = *state_ptr;
|
||||||
API::refresh_window(widget_->handle());
|
if (unknown_)
|
||||||
return max_;
|
value_px_ = 0;
|
||||||
|
else
|
||||||
|
value_ = (std::min)(value_, max_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::unknown(bool enb)
|
|
||||||
{
|
|
||||||
unknown_ = enb;
|
|
||||||
if(enb)
|
|
||||||
draw_width_ = static_cast<unsigned>(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trigger::unknown() const
|
|
||||||
{
|
|
||||||
return unknown_;
|
return unknown_;
|
||||||
}
|
}
|
||||||
bool trigger::stopped() const
|
|
||||||
|
unsigned value_px() const
|
||||||
{
|
{
|
||||||
return stop_;
|
return value_px_;
|
||||||
}
|
}
|
||||||
bool trigger::stop(bool s)
|
private:
|
||||||
|
void _m_try_refresh()
|
||||||
{
|
{
|
||||||
std::swap(s,stop_);
|
if (nullptr == widget_)
|
||||||
return s;
|
return;
|
||||||
|
|
||||||
|
auto value_px = (widget_->size().width - border_px * 2) * value_ / max_;
|
||||||
|
|
||||||
|
if (value_px != value_px_)
|
||||||
|
{
|
||||||
|
value_px_ = value_px;
|
||||||
|
API::refresh_window(*widget_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
nana::progress * widget_{ nullptr };
|
||||||
|
unsigned max_{ 100 };
|
||||||
|
unsigned value_{ 0 };
|
||||||
|
unsigned value_px_{ 0 };
|
||||||
|
bool unknown_{ false };
|
||||||
|
};
|
||||||
|
|
||||||
|
trigger::trigger()
|
||||||
|
: progress_(new substance)
|
||||||
|
{}
|
||||||
|
|
||||||
|
trigger::~trigger()
|
||||||
|
{
|
||||||
|
delete progress_;
|
||||||
|
}
|
||||||
|
|
||||||
|
substance* trigger::progress() const
|
||||||
|
{
|
||||||
|
return progress_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void trigger::attached(widget_reference wdg, graph_reference)
|
||||||
|
{
|
||||||
|
progress_->set_widget(wdg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::refresh(graph_reference graph)
|
void trigger::refresh(graph_reference graph)
|
||||||
{
|
{
|
||||||
if (false == unknown_)
|
const unsigned border_px = substance::border_px;
|
||||||
draw_width_ = static_cast<unsigned>((graph.width() - border * 2) * (double(value_) / max_));
|
|
||||||
|
|
||||||
_m_draw_box(graph);
|
unsigned width = graph.width() - border_px * 2;
|
||||||
_m_draw_progress(graph);
|
unsigned height = graph.height() - border_px * 2;
|
||||||
}
|
|
||||||
|
|
||||||
void trigger::_m_draw_box(graph_reference graph)
|
rectangle rt_val{ graph.size() };
|
||||||
|
|
||||||
|
rt_val.pare_off(static_cast<int>(border_px));
|
||||||
|
|
||||||
|
auto rt_bground = rt_val;
|
||||||
|
if (false == progress_->unknown(nullptr))
|
||||||
{
|
{
|
||||||
rectangle r{ graph.size() };
|
rt_bground.x = static_cast<int>(progress_->value_px()) + static_cast<int>(border_px);
|
||||||
graph.gradual_rectangle(r, colors::button_face_shadow_end, colors::button_face_shadow_start, true);
|
rt_bground.width -= progress_->value_px();
|
||||||
::nana::color lt{ colors::gray }, rb{colors::white};
|
|
||||||
graph.frame_rectangle(r, lt, lt, rb, rb);
|
|
||||||
}
|
|
||||||
|
|
||||||
void trigger::_m_draw_progress(graph_reference graph)
|
rt_val.width = progress_->value_px();
|
||||||
{
|
|
||||||
unsigned width = graph.width() - border * 2;
|
|
||||||
unsigned height = graph.height() - border * 2;
|
|
||||||
|
|
||||||
if(false == unknown_)
|
|
||||||
{
|
|
||||||
if(draw_width_)
|
|
||||||
graph.gradual_rectangle({ static_cast<int>(border), static_cast<int>(border), draw_width_, height }, { 0x6F, 0xFF, 0xA8 }, { 0x10, 0x75, 0x15 }, true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned block = width / 3;
|
auto const block = width / 3;
|
||||||
|
|
||||||
int left = (value_ < block ? 0 : value_ - block) + border;
|
auto const value = progress_->value(nullptr);
|
||||||
int right = (value_ >= width - 1 + border? width - 1 + border: value_);
|
|
||||||
|
|
||||||
if(right >= left)
|
auto left = (std::max)(0, static_cast<int>(value - block)) + static_cast<int>(border_px);
|
||||||
graph.gradual_rectangle({ left, static_cast<int>(border), static_cast<unsigned>(right - left + 1), height }, { 0x6F, 0xFF, 0xA8 }, { 0x10, 0x75, 0x15 }, true);
|
auto right = static_cast<int>((std::min)(value, width + border_px -1));
|
||||||
|
|
||||||
if(value_ >= width + block) value_ = 0;
|
if (right > left)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trigger::_m_check_changing(unsigned newvalue) const
|
|
||||||
{
|
{
|
||||||
if(graph_)
|
rt_val.x = left;
|
||||||
return (((graph_->width() - border * 2) * newvalue / max_) != draw_width_);
|
rt_val.width = static_cast<unsigned>(right - left + 1);
|
||||||
return false;
|
}
|
||||||
|
else
|
||||||
|
rt_val.width = 0;
|
||||||
|
|
||||||
|
if (value >= width + block)
|
||||||
|
progress_->reset_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto & sch = progress_->widget_ptr()->scheme();
|
||||||
|
|
||||||
|
//Draw the gradient background if gradient_bgcolor is available.
|
||||||
|
|
||||||
|
auto bgcolor = sch.background.get_color();
|
||||||
|
if (bgcolor.invisible())
|
||||||
|
bgcolor = colors::button_face;
|
||||||
|
|
||||||
|
if (sch.gradient_bgcolor.get_color().invisible())
|
||||||
|
graph.rectangle(rt_bground, true, bgcolor);
|
||||||
|
else
|
||||||
|
graph.gradual_rectangle(rt_bground, bgcolor, sch.gradient_bgcolor.get_color(), true);
|
||||||
|
|
||||||
|
//Draw the gradient fgcolor if gradient_fgcolor is available.
|
||||||
|
|
||||||
|
auto fgcolor = sch.foreground.get_color();
|
||||||
|
if (fgcolor.invisible())
|
||||||
|
fgcolor = static_cast<color_rgb>(0x107515);
|
||||||
|
|
||||||
|
if (sch.gradient_fgcolor.get_color().invisible())
|
||||||
|
graph.rectangle(rt_val, true, fgcolor);
|
||||||
|
else
|
||||||
|
graph.gradual_rectangle(rt_val, sch.gradient_fgcolor.get_color(), fgcolor, true);
|
||||||
|
|
||||||
|
graph.frame_rectangle(rectangle{ graph.size() }, colors::gray, colors::gray, colors::white, colors::white);
|
||||||
}
|
}
|
||||||
//end class drawer
|
|
||||||
}//end namespace progress
|
}//end namespace progress
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
@ -165,49 +216,42 @@ namespace nana
|
|||||||
|
|
||||||
unsigned progress::value() const
|
unsigned progress::value() const
|
||||||
{
|
{
|
||||||
return get_drawer_trigger().value();
|
return get_drawer_trigger().progress()->value(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned progress::value(unsigned val)
|
unsigned progress::value(unsigned val)
|
||||||
{
|
{
|
||||||
internal_scope_guard isg;
|
internal_scope_guard lock;
|
||||||
if(API::empty_window(this->handle()) == false)
|
if(API::empty_window(this->handle()) == false)
|
||||||
return get_drawer_trigger().value(val);
|
return get_drawer_trigger().progress()->value(&val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned progress::inc()
|
unsigned progress::inc()
|
||||||
{
|
{
|
||||||
internal_scope_guard isg;
|
internal_scope_guard lock;
|
||||||
return get_drawer_trigger().inc();
|
return get_drawer_trigger().progress()->inc();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned progress::amount() const
|
unsigned progress::amount() const
|
||||||
{
|
{
|
||||||
return get_drawer_trigger().Max();
|
return get_drawer_trigger().progress()->maximum(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned progress::amount(unsigned value)
|
unsigned progress::amount(unsigned value)
|
||||||
{
|
{
|
||||||
return get_drawer_trigger().Max(value);
|
return get_drawer_trigger().progress()->maximum(&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void progress::unknown(bool enb)
|
void progress::unknown(bool enb)
|
||||||
{
|
{
|
||||||
get_drawer_trigger().unknown(enb);
|
internal_scope_guard lock;
|
||||||
|
get_drawer_trigger().progress()->unknown(&enb);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool progress::unknown() const
|
bool progress::unknown() const
|
||||||
{
|
{
|
||||||
return get_drawer_trigger().unknown();
|
return get_drawer_trigger().progress()->unknown(nullptr);
|
||||||
}
|
|
||||||
bool progress::stop(bool s)
|
|
||||||
{
|
|
||||||
return get_drawer_trigger().stop(s);
|
|
||||||
}
|
|
||||||
bool progress::stopped() const
|
|
||||||
{
|
|
||||||
return get_drawer_trigger().stopped();
|
|
||||||
}
|
}
|
||||||
//end class progress
|
//end class progress
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
@ -887,6 +887,7 @@ namespace nana{ namespace widgets
|
|||||||
return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0);
|
return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
/// Split a text into multiple sections, a section indicates an english word or a CKJ character
|
||||||
void _m_text_section(const std::wstring& str, std::vector<text_section>& tsec)
|
void _m_text_section(const std::wstring& str, std::vector<text_section>& tsec)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
@ -1025,14 +1026,14 @@ namespace nana{ namespace widgets
|
|||||||
if (pos)
|
if (pos)
|
||||||
{
|
{
|
||||||
auto chr = text[pos - 1];
|
auto chr = text[pos - 1];
|
||||||
if ((std::iswalpha(chr) && !std::isspace(chr)) || chr == '_')
|
if ((std::iswalpha(chr) && !std::iswspace(chr)) || chr == '_')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos + len < text.size())
|
if (pos + len < text.size())
|
||||||
{
|
{
|
||||||
auto chr = text[pos + len];
|
auto chr = text[pos + len];
|
||||||
if ((std::iswalpha(chr) && !std::isspace(chr)) || chr == '_')
|
if ((std::iswalpha(chr) && !std::iswspace(chr)) || chr == '_')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1596,18 +1597,6 @@ namespace nana{ namespace widgets
|
|||||||
if(!attributes_.enable_caret)
|
if(!attributes_.enable_caret)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto is_whitespace = [](wchar_t c) {
|
|
||||||
switch (c) {
|
|
||||||
case L' ':
|
|
||||||
case L'\t':
|
|
||||||
case L'\n':
|
|
||||||
case L'\r':
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set caret pos by screen point and get the caret pos.
|
// Set caret pos by screen point and get the caret pos.
|
||||||
mouse_caret(arg.pos, true);
|
mouse_caret(arg.pos, true);
|
||||||
|
|
||||||
@ -1616,11 +1605,11 @@ namespace nana{ namespace widgets
|
|||||||
const auto& line = impl_->textbase.getline(select_.b.y);
|
const auto& line = impl_->textbase.getline(select_.b.y);
|
||||||
|
|
||||||
// Expand the selection forward to the word's end.
|
// Expand the selection forward to the word's end.
|
||||||
while (select_.b.x < line.size() && !is_whitespace(line[select_.b.x]))
|
while (select_.b.x < line.size() && !std::iswspace(line[select_.b.x]))
|
||||||
++select_.b.x;
|
++select_.b.x;
|
||||||
|
|
||||||
// Expand the selection backward to the word's start.
|
// Expand the selection backward to the word's start.
|
||||||
while (select_.a.x > 0 && !is_whitespace(line[select_.a.x - 1]))
|
while (select_.a.x > 0 && !std::iswspace(line[select_.a.x - 1]))
|
||||||
--select_.a.x;
|
--select_.a.x;
|
||||||
|
|
||||||
select_.mode_selection = selection::mode::method_selected;
|
select_.mode_selection = selection::mode::method_selected;
|
||||||
@ -2876,7 +2865,6 @@ namespace nana{ namespace widgets
|
|||||||
return ('0' <= ch && ch <= '9');
|
return ('0' <= ch && ch <= '9');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
::nana::color text_editor::_m_bgcolor() const
|
::nana::color text_editor::_m_bgcolor() const
|
||||||
{
|
{
|
||||||
return (!API::window_enabled(window_) ? static_cast<color_rgb>(0xE0E0E0) : API::bgcolor(window_));
|
return (!API::window_enabled(window_) ? static_cast<color_rgb>(0xE0E0E0) : API::bgcolor(window_));
|
||||||
|
@ -524,14 +524,16 @@ namespace nana
|
|||||||
if((::nana::mouse_action::pressed == slider_state_.mouse_state) && (API::capture_window() == this->other_.wd))
|
if((::nana::mouse_action::pressed == slider_state_.mouse_state) && (API::capture_window() == this->other_.wd))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto state_changed = ((slider_state_.mouse_state != ::nana::mouse_action::normal)
|
||||||
|
|| (attr_.adorn_pos != attr_.slider.pos));
|
||||||
|
|
||||||
slider_state_.mouse_state = ::nana::mouse_action::normal;
|
slider_state_.mouse_state = ::nana::mouse_action::normal;
|
||||||
attr_.is_draw_adorn = false;
|
attr_.is_draw_adorn = false;
|
||||||
if(attr_.adorn_pos != attr_.slider.pos)
|
|
||||||
{
|
|
||||||
attr_.adorn_pos = attr_.slider.pos;
|
attr_.adorn_pos = attr_.slider.pos;
|
||||||
return true;
|
slider_state_.mouse_state = ::nana::mouse_action::normal;
|
||||||
}
|
|
||||||
return false;
|
return state_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user