add some missing files, refactor group
This commit is contained in:
@@ -9,55 +9,78 @@
|
||||
*
|
||||
* @file: nana/gui/widgets/group.cpp
|
||||
*
|
||||
* @contributors: Stefan Pfeifer (st-321), Jinhao, Ariel Vina-Rodriguez (qPCR4vir)
|
||||
* @Author: Stefan Pfeifer(st-321), Ariel Vina-Rodriguez (qPCR4vir)
|
||||
*
|
||||
* @brief group is a widget used to visually group and layout other widgets.
|
||||
*/
|
||||
|
||||
|
||||
#include <nana/gui/widgets/group.hpp>
|
||||
#include <nana/gui/widgets/label.hpp>
|
||||
#include <nana/gui/drawing.hpp>
|
||||
|
||||
namespace nana{
|
||||
group::group( window parent, ///<
|
||||
string titel_ /*={}*/, ///<
|
||||
bool format /*=false*/, ///<
|
||||
unsigned gap /*=2*/, ///<
|
||||
rectangle r /*={} */ ///<
|
||||
|
||||
struct group::implement
|
||||
{
|
||||
label caption;
|
||||
};
|
||||
|
||||
group::group( window parent, ///<
|
||||
std::wstring titel_ /*={}*/, ///<
|
||||
bool format /*=false*/, ///<
|
||||
unsigned gap /*=2*/, ///<
|
||||
rectangle r /*={} */ ///<
|
||||
)
|
||||
: panel (parent, r),
|
||||
titel (*this, titel_)
|
||||
{
|
||||
titel.format(format);
|
||||
::nana::size sz = titel.measure(1000);
|
||||
std::stringstream ft;
|
||||
: panel (parent, r),
|
||||
impl_(new implement)
|
||||
{
|
||||
impl_->caption.create(*this);
|
||||
impl_->caption.format(format);
|
||||
::nana::size sz = impl_->caption.measure(1000);
|
||||
std::stringstream ft;
|
||||
|
||||
ft << "vert margin=[0," << gap << "," << gap << "," << gap << "]"
|
||||
<< " <weight=" << sz.height << " <weight=5> <titel weight=" << sz.width+1 << "> >"
|
||||
<< " <content>";
|
||||
plc_outer.div(ft.str().c_str());
|
||||
|
||||
plc_outer["titel" ] << impl_->caption;
|
||||
plc_outer["content"] << content;
|
||||
plc_outer.collocate();
|
||||
|
||||
color pbg = API::bgcolor( parent);
|
||||
impl_->caption.bgcolor(pbg.blend(colors::black, 0.975) );
|
||||
color bg=pbg.blend(colors::black, 0.950 );
|
||||
|
||||
bgcolor(pbg);
|
||||
content.bgcolor(bg);
|
||||
|
||||
drawing dw(*this);
|
||||
|
||||
// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
|
||||
dw.draw([gap, sz, bg, pbg](paint::graphics& graph)
|
||||
{
|
||||
graph.rectangle(true, pbg);
|
||||
graph.round_rectangle(rectangle(point(gap - 1, sz.height / 2),
|
||||
nana::size(graph.width() - 2 * (gap - 1), graph.height() - sz.height / 2 - (gap - 1))
|
||||
),
|
||||
3, 3, colors::gray_border, true, bg);
|
||||
});
|
||||
}
|
||||
|
||||
ft << "vertical margin=[0," << gap << "," << gap << "," << gap << "]"
|
||||
<< " <weight=" << sz.height << " <weight=5> <titel weight=" << sz.width+1 << "> >"
|
||||
<< " <content>";
|
||||
plc_outer.div(ft.str().c_str());
|
||||
group::~group()
|
||||
{
|
||||
}
|
||||
|
||||
plc_outer["titel" ] << titel;
|
||||
plc_outer["content"] << content;
|
||||
plc_outer.collocate();
|
||||
|
||||
color pbg = API::bgcolor( parent);
|
||||
titel.bgcolor(pbg.blend(colors::black, 0.975) );
|
||||
color bg=pbg.blend(colors::black, 0.950 );
|
||||
bgcolor(pbg);
|
||||
content.bgcolor(bg);
|
||||
|
||||
drawing dw(*this);
|
||||
|
||||
// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
|
||||
dw.draw([gap,sz,bg,pbg](paint::graphics& graph)
|
||||
{
|
||||
graph.rectangle(true, pbg);
|
||||
graph.round_rectangle(rectangle( point ( gap-1 , sz.height/2 ),
|
||||
nana::size (graph.width()-2*(gap-1), graph.height()-sz.height/2-(gap-1))
|
||||
),
|
||||
3,3, colors::gray_border, true, bg);
|
||||
});
|
||||
}
|
||||
::nana::string group::_m_caption() const
|
||||
{
|
||||
return impl_->caption.caption();
|
||||
}
|
||||
|
||||
void group::_m_caption(::nana::string&& str)
|
||||
{
|
||||
return impl_->caption.caption(std::move(str));
|
||||
}
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
Reference in New Issue
Block a user