diff --git a/include/nana/gui/widgets/group.hpp b/include/nana/gui/widgets/group.hpp index 86ca663b..ba48928b 100644 --- a/include/nana/gui/widgets/group.hpp +++ b/include/nana/gui/widgets/group.hpp @@ -22,8 +22,20 @@ #include namespace nana{ + + namespace drawerbase + { + namespace group + { + struct scheme : public nana::widget_geometrics + { + color_proxy border{ colors::gray_border }; + }; + }// end namespace panel + }//end namespace drawerbase + class group - : public panel + : public widget_object { struct implement; public: @@ -53,6 +65,9 @@ namespace nana{ /// Adds an option for user selection checkbox& add_option(::std::string); + /// Modifies the alignment of the title + void caption_align(align position); + /// Enables/disables the radio mode which is single selection group& radio_mode(bool); diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index 23cc287c..f976944a 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -35,6 +35,7 @@ namespace nana{ struct group::implement { label caption; + align caption_align{ align::left }; place place_content; unsigned gap{2}; std::string usr_div_str; @@ -65,10 +66,30 @@ namespace nana{ void update_div() { + const std::size_t padding = 10; caption_dimension = caption.measure(1000); + caption_dimension.width += 1; std::string div = "vert margin=[0," + std::to_string(gap) + "," + std::to_string(gap + 5) + "," + std::to_string(gap) + "]"; +#if 0 div += "<" + field_title + " weight=" + std::to_string(caption_dimension.width + 1) + ">>"; +#else + div += ""; + else + div += "<>"; //right or center + + div += "<" + std::string{ field_title } + " weight=" + std::to_string(caption_dimension.width) + ">"; + + if (align::right == caption_align) + div += ""; + else if (align::center == caption_align) + div += "<>"; + + div += ">"; +#endif div += "<"; if (!usr_div_str.empty()) @@ -97,10 +118,15 @@ namespace nana{ create(parent, r, vsb); } + using groupbase_type = widget_object; + group::group(window parent, ::std::string titel, bool formatted, unsigned gap, const rectangle& r, bool vsb) - : panel(parent, r, vsb), - impl_(new implement(*this, std::move(titel), vsb, gap)) { + this->create(parent, r, vsb); + this->bgcolor(API::bgcolor(parent)); + + impl_.reset(new implement(*this, std::move(titel), vsb, gap)); + impl_->caption.format(formatted); _m_init(); } @@ -128,6 +154,17 @@ namespace nana{ return *impl_->options.back(); } + void group::caption_align(align position) + { + if (position != impl_->caption_align) + { + impl_->caption_align = position; + impl_->update_div(); + impl_->place_content.collocate(); + API::refresh_window(*this); + } + } + group& group::radio_mode(bool enable) { _THROW_IF_EMPTY() @@ -243,7 +280,7 @@ namespace nana{ graph.round_rectangle(rectangle(point(gap_px, top_round_line), nana::size(graph.width() - 2 * gap_px, graph.height() - top_round_line - gap_px) ), - 3, 3, colors::gray_border, true, this->bgcolor()); + 3, 3, this->scheme().border, true, this->bgcolor()); auto opt_r = API::window_rectangle(impl_->caption); if (opt_r) @@ -263,11 +300,8 @@ namespace nana{ void group::_m_complete_creation() { - panel::_m_complete_creation(); - + widget::_m_complete_creation(); impl_->create(handle()); - - _m_init(); } diff --git a/source/gui/widgets/label.cpp b/source/gui/widgets/label.cpp index 7f4f2a4e..790ae3b8 100644 --- a/source/gui/widgets/label.cpp +++ b/source/gui/widgets/label.cpp @@ -1,7 +1,7 @@ /* * A Label Control Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-208 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at