develop group
This commit is contained in:
parent
e788c57512
commit
19a44b772b
@ -1,12 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* A filesystem Implementation
|
* A filesystem Implementation
|
||||||
* Copyright(C) 2003 Jinhao(cnjinhao@hotmail.com)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
|
* Copyright(C) 2003-2015 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
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
* @file: stdex/filesystem/filesystem.hpp
|
* @file: nana/filesystem/filesystem.hpp
|
||||||
* @description:
|
* @description:
|
||||||
* file_iterator is a toolkit for applying each file and directory in a
|
* file_iterator is a toolkit for applying each file and directory in a
|
||||||
* specified path.
|
* specified path.
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
* @file: nana/gui/widgets/group.hpp
|
* @file: nana/gui/widgets/group.hpp
|
||||||
*
|
*
|
||||||
* @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.
|
* @brief group is a widget used to visually group and layout other widgets.
|
||||||
*/
|
*/
|
||||||
@ -21,27 +21,34 @@
|
|||||||
#include <nana/gui/widgets/panel.hpp>
|
#include <nana/gui/widgets/panel.hpp>
|
||||||
|
|
||||||
namespace nana{
|
namespace nana{
|
||||||
class group
|
class group
|
||||||
: public panel<true>
|
: public panel<true>
|
||||||
{
|
{
|
||||||
place plc_outer{*this};
|
|
||||||
panel<false> content {*this};
|
|
||||||
place plc_inner{content};
|
|
||||||
|
|
||||||
struct implement;
|
struct implement;
|
||||||
public:
|
public:
|
||||||
group( window parent, ///<
|
group( window parent, ///<
|
||||||
std::wstring titel_ ={STR("")}, ///<
|
std::wstring titel_ ={STR("")}, ///<
|
||||||
bool format =false, ///< Use a formated label?
|
bool format =false, ///< Use a formated label?
|
||||||
unsigned gap =2, ///< betwen the content and the external limit
|
unsigned gap =2, ///< betwen the content and the external limit
|
||||||
rectangle r ={} ///<
|
rectangle r ={} ///<
|
||||||
);
|
);
|
||||||
|
|
||||||
~group();
|
~group();
|
||||||
|
|
||||||
place& plc (){ return plc_inner; }
|
place& get_place();
|
||||||
window inner(){ return content; }
|
|
||||||
|
template<typename Widget, typename ...Args>
|
||||||
|
Widget* create_child(const char* field, Args && ... args)
|
||||||
|
{
|
||||||
|
auto wdg = new Widget(inner(), std::forward<Args>(args)...);
|
||||||
|
_m_add_child(field, wdg);
|
||||||
|
return wdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
window inner();
|
||||||
private:
|
private:
|
||||||
|
void _m_add_child(const char* field, widget*);
|
||||||
|
|
||||||
::nana::string _m_caption() const override;
|
::nana::string _m_caption() const override;
|
||||||
void _m_caption(::nana::string&&) override;
|
void _m_caption(::nana::string&&) override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -23,7 +23,17 @@ namespace nana{
|
|||||||
|
|
||||||
struct group::implement
|
struct group::implement
|
||||||
{
|
{
|
||||||
label caption;
|
label caption;
|
||||||
|
panel<false> content;
|
||||||
|
place place_outter;
|
||||||
|
place place_content;
|
||||||
|
|
||||||
|
implement(group* host):
|
||||||
|
caption(*host),
|
||||||
|
content(*host),
|
||||||
|
place_outter(*host),
|
||||||
|
place_content(content)
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
group::group( window parent, ///<
|
group::group( window parent, ///<
|
||||||
@ -33,28 +43,30 @@ namespace nana{
|
|||||||
rectangle r /*={} */ ///<
|
rectangle r /*={} */ ///<
|
||||||
)
|
)
|
||||||
: panel (parent, r),
|
: panel (parent, r),
|
||||||
impl_(new implement)
|
impl_(new implement(this))
|
||||||
{
|
{
|
||||||
impl_->caption.create(*this);
|
|
||||||
impl_->caption.format(format);
|
impl_->caption.format(format);
|
||||||
::nana::size sz = impl_->caption.measure(1000);
|
::nana::size sz = impl_->caption.measure(1000);
|
||||||
std::stringstream ft;
|
std::stringstream ft;
|
||||||
|
|
||||||
ft << "vert margin=[0," << gap << "," << gap << "," << gap << "]"
|
ft << "vert margin=[0," << gap << ","<<gap<<","<<gap<<"]"
|
||||||
<< " <weight=" << sz.height << " <weight=5> <titel weight=" << sz.width+1 << "> >"
|
<< " <weight=" << sz.height << " <weight=5> <titel weight=" << sz.width+1 << "> >"
|
||||||
<< " <content>";
|
<< " <content>";
|
||||||
plc_outer.div(ft.str().c_str());
|
|
||||||
|
auto & outter = impl_->place_outter;
|
||||||
|
|
||||||
|
outter.div(ft.str().c_str());
|
||||||
|
|
||||||
plc_outer["titel" ] << impl_->caption;
|
outter["titel"] << impl_->caption;
|
||||||
plc_outer["content"] << content;
|
outter["content"] << impl_->content;
|
||||||
plc_outer.collocate();
|
outter.collocate();
|
||||||
|
|
||||||
color pbg = API::bgcolor( parent);
|
color pbg = API::bgcolor( parent);
|
||||||
impl_->caption.bgcolor(pbg.blend(colors::black, 0.975) );
|
impl_->caption.bgcolor(pbg.blend(colors::black, 0.975) );
|
||||||
color bg=pbg.blend(colors::black, 0.950 );
|
color bg=pbg.blend(colors::black, 0.950 );
|
||||||
|
|
||||||
bgcolor(pbg);
|
bgcolor(pbg);
|
||||||
content.bgcolor(bg);
|
impl_->content.bgcolor(bg);
|
||||||
|
|
||||||
drawing dw(*this);
|
drawing dw(*this);
|
||||||
|
|
||||||
@ -73,6 +85,21 @@ namespace nana{
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
place& group::get_place()
|
||||||
|
{
|
||||||
|
return impl_->place_content;
|
||||||
|
}
|
||||||
|
|
||||||
|
window group::inner()
|
||||||
|
{
|
||||||
|
return impl_->content;
|
||||||
|
}
|
||||||
|
|
||||||
|
void group::_m_add_child(const char* field, widget* wdg)
|
||||||
|
{
|
||||||
|
impl_->place_content[field] << wdg->handle();
|
||||||
|
}
|
||||||
|
|
||||||
::nana::string group::_m_caption() const
|
::nana::string group::_m_caption() const
|
||||||
{
|
{
|
||||||
return impl_->caption.caption();
|
return impl_->caption.caption();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user