Partial implementation of missing nana::typeface()
This commit is contained in:
parent
e7bc1405ec
commit
1d2c7f85f4
@ -77,6 +77,9 @@ namespace nana{
|
||||
/// 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;
|
||||
|
||||
/// Change typeface of caption label ( does not effect child widgets )
|
||||
void typeface( const nana::paint::font& font );
|
||||
|
||||
group& enable_format_caption(bool format);
|
||||
|
||||
group& collocate() noexcept;
|
||||
|
||||
@ -27,13 +27,14 @@
|
||||
if(empty()) \
|
||||
throw std::logic_error("the group is invalid");
|
||||
|
||||
namespace nana{
|
||||
namespace nana
|
||||
{
|
||||
|
||||
static const char* field_title = "__nana_group_title__";
|
||||
static const char* field_options = "__nana_group_options__";
|
||||
static const char* field_title = "__nana_group_title__";
|
||||
static const char* field_options = "__nana_group_options__";
|
||||
|
||||
struct group::implement
|
||||
{
|
||||
struct group::implement
|
||||
{
|
||||
label caption;
|
||||
align caption_align{ align::left };
|
||||
place place_content;
|
||||
@ -101,43 +102,43 @@ namespace nana{
|
||||
if (caption.caption().empty())
|
||||
place_content.field_display(field_title, false);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
group::group()
|
||||
group::group()
|
||||
: impl_(new implement)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
group::group(window parent, const rectangle& r, bool vsb)
|
||||
group::group(window parent, const rectangle& r, bool vsb)
|
||||
: group()
|
||||
{
|
||||
{
|
||||
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)
|
||||
{
|
||||
{
|
||||
this->bgcolor(API::bgcolor(parent));
|
||||
|
||||
impl_.reset(new implement(*this, std::move(titel), vsb, gap));
|
||||
|
||||
impl_->caption.format(formatted);
|
||||
_m_init();
|
||||
}
|
||||
}
|
||||
|
||||
group::~group()
|
||||
{
|
||||
group::~group()
|
||||
{
|
||||
delete impl_->radio_logic;
|
||||
}
|
||||
}
|
||||
|
||||
checkbox& group::add_option(std::string text)
|
||||
{
|
||||
checkbox& group::add_option(std::string text)
|
||||
{
|
||||
_THROW_IF_EMPTY()
|
||||
|
||||
#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
|
||||
impl_->options.emplace_back(new checkbox(handle()));
|
||||
auto & opt = impl_->options.back();
|
||||
@ -152,10 +153,10 @@ namespace nana{
|
||||
impl_->radio_logic->add(*opt);
|
||||
|
||||
return *impl_->options.back();
|
||||
}
|
||||
}
|
||||
|
||||
void group::caption_align(align position)
|
||||
{
|
||||
void group::caption_align(align position)
|
||||
{
|
||||
if (position != impl_->caption_align)
|
||||
{
|
||||
impl_->caption_align = position;
|
||||
@ -163,10 +164,10 @@ namespace nana{
|
||||
impl_->place_content.collocate();
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group& group::radio_mode(bool enable)
|
||||
{
|
||||
group& group::radio_mode(bool enable)
|
||||
{
|
||||
_THROW_IF_EMPTY()
|
||||
|
||||
if (enable)
|
||||
@ -185,38 +186,52 @@ namespace nana{
|
||||
impl_->radio_logic = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t group::option() const
|
||||
{
|
||||
std::size_t group::option() const
|
||||
{
|
||||
_THROW_IF_EMPTY();
|
||||
|
||||
if (impl_->radio_logic)
|
||||
return impl_->radio_logic->checked();
|
||||
|
||||
throw std::logic_error("the radio_mode of the group is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
bool group::option_checked(std::size_t pos) const
|
||||
{
|
||||
bool group::option_checked(std::size_t pos) const
|
||||
{
|
||||
_THROW_IF_EMPTY();
|
||||
return impl_->options.at(pos)->checked();
|
||||
}
|
||||
}
|
||||
|
||||
group& group::enable_format_caption(bool format)
|
||||
{
|
||||
void group::typeface( const nana::paint::font& font )
|
||||
{
|
||||
// change typeface of caption label
|
||||
impl_->caption.typeface( font );
|
||||
|
||||
/* change size of caption label
|
||||
|
||||
The caption may be changed AFTER this call
|
||||
so the neccessary label size is unknown
|
||||
set it to 80% of the current widget width and 50 pixels
|
||||
*/
|
||||
impl_->caption.move( rectangle(0,0,size().width * 0.8,50));
|
||||
}
|
||||
|
||||
group& group::enable_format_caption(bool format)
|
||||
{
|
||||
impl_->caption.format(format);
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
group& group::collocate() noexcept
|
||||
{
|
||||
group& group::collocate() noexcept
|
||||
{
|
||||
impl_->place_content.collocate();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
group& group::div(const char* div_str) noexcept
|
||||
{
|
||||
group& group::div(const char* div_str) noexcept
|
||||
{
|
||||
if (div_str)
|
||||
impl_->usr_div_str = div_str;
|
||||
else
|
||||
@ -224,35 +239,35 @@ namespace nana{
|
||||
|
||||
impl_->update_div();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
group::field_reference group::operator[](const char* field)
|
||||
{
|
||||
group::field_reference group::operator[](const char* field)
|
||||
{
|
||||
return impl_->place_content.field(field);
|
||||
}
|
||||
}
|
||||
|
||||
void group::field_display(const char* field_name, bool display)
|
||||
{
|
||||
void group::field_display(const char* field_name, bool display)
|
||||
{
|
||||
impl_->place_content.field_display(field_name, display);
|
||||
}
|
||||
}
|
||||
|
||||
bool group::field_display(const char* field_name) const
|
||||
{
|
||||
bool group::field_display(const char* field_name) const
|
||||
{
|
||||
return impl_->place_content.field_display(field_name);
|
||||
}
|
||||
}
|
||||
|
||||
void group::erase(window handle)
|
||||
{
|
||||
void group::erase(window handle)
|
||||
{
|
||||
impl_->place_content.erase(handle);
|
||||
}
|
||||
}
|
||||
|
||||
void group::_m_add_child(const char* field, widget* wdg)
|
||||
{
|
||||
void group::_m_add_child(const char* field, widget* wdg)
|
||||
{
|
||||
impl_->place_content[field] << wdg->handle();
|
||||
}
|
||||
}
|
||||
|
||||
void group::_m_init()
|
||||
{
|
||||
void group::_m_init()
|
||||
{
|
||||
this->div(nullptr);
|
||||
|
||||
auto & outter = impl_->place_content;
|
||||
@ -271,7 +286,8 @@ namespace nana{
|
||||
//When the group is resized, the drawing is called before moving the caption, but
|
||||
//the drawing of group requires the lastest position of caption for gradual rectangle.
|
||||
//For the requirement, a move event handler is required for listning the change of caption's position.
|
||||
impl_->caption.events().move([this](const arg_move&){
|
||||
impl_->caption.events().move([this](const arg_move&)
|
||||
{
|
||||
if (align::left != impl_->caption_align)
|
||||
API::refresh_window(*this);
|
||||
});
|
||||
@ -302,25 +318,25 @@ namespace nana{
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void group::_m_complete_creation()
|
||||
{
|
||||
void group::_m_complete_creation()
|
||||
{
|
||||
widget::_m_complete_creation();
|
||||
impl_->create(handle());
|
||||
_m_init();
|
||||
}
|
||||
}
|
||||
|
||||
auto group::_m_caption() const noexcept -> native_string_type
|
||||
{
|
||||
auto group::_m_caption() const noexcept -> native_string_type
|
||||
{
|
||||
return impl_->caption.caption_native();
|
||||
}
|
||||
}
|
||||
|
||||
void group::_m_caption(native_string_type&& str)
|
||||
{
|
||||
void group::_m_caption(native_string_type&& str)
|
||||
{
|
||||
impl_->caption.caption(std::move(str));
|
||||
impl_->update_div();
|
||||
impl_->place_content.collocate();
|
||||
}
|
||||
}
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user