modify group methods, fix a compiling-error
This commit is contained in:
		
							parent
							
								
									19a44b772b
								
							
						
					
					
						commit
						be031e9b7f
					
				@ -514,27 +514,27 @@ namespace nana
 | 
				
			|||||||
	struct general_events
 | 
						struct general_events
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		virtual ~general_events(){}
 | 
							virtual ~general_events(){}
 | 
				
			||||||
		basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
 | 
							basic_event<arg_mouse> mouse_enter;	///< the cursor enters the window
 | 
				
			||||||
		basic_event<arg_mouse> mouse_move;  ///< the cursor moves on the window
 | 
							basic_event<arg_mouse> mouse_move;	///< the cursor moves on the window
 | 
				
			||||||
		basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window
 | 
							basic_event<arg_mouse> mouse_leave;	///< the cursor leaves the window
 | 
				
			||||||
		basic_event<arg_mouse> mouse_down;  ///< the user presses the mouse button
 | 
							basic_event<arg_mouse> mouse_down;	///< the user presses the mouse button
 | 
				
			||||||
		basic_event<arg_mouse> mouse_up;    ///< the user presses the mouse button
 | 
							basic_event<arg_mouse> mouse_up;	///< the user presses the mouse button
 | 
				
			||||||
		basic_event<arg_mouse> click;       ///< the window is clicked, but occurs after mouse_down and before mouse_up
 | 
							basic_event<arg_mouse> click;		///< the window is clicked, but occurs after mouse_down and before mouse_up
 | 
				
			||||||
		basic_event<arg_mouse> dbl_click;   ///< the window is double clicked
 | 
							basic_event<arg_mouse> dbl_click;	///< the window is double clicked
 | 
				
			||||||
		basic_event<arg_wheel> mouse_wheel; ///< the mouse wheel rotates while the window has focus
 | 
							basic_event<arg_wheel> mouse_wheel;	///< the mouse wheel rotates while the window has focus
 | 
				
			||||||
		basic_event<arg_dropfiles>	mouse_dropfiles; ///< the mouse drops some external data while the window enable accepting files
 | 
							basic_event<arg_dropfiles>	mouse_dropfiles; ///< the mouse drops some external data while the window enable accepting files
 | 
				
			||||||
		basic_event<arg_expose>	expose;     ///< the visibility changes
 | 
							basic_event<arg_expose>	expose;		///< the visibility changes
 | 
				
			||||||
		basic_event<arg_focus>	focus;      ///< the window receives or loses keyboard focus
 | 
							basic_event<arg_focus>	focus;		///< the window receives or loses keyboard focus
 | 
				
			||||||
		basic_event<arg_keyboard>	key_press;   ///< a key is pressed while the window has focus. event code is event_code::key_press
 | 
							basic_event<arg_keyboard>	key_press;   ///< a key is pressed while the window has focus. event code is event_code::key_press
 | 
				
			||||||
		basic_event<arg_keyboard>	key_release; ///< a key is released while the window has focus. event code is event_code::key_release
 | 
							basic_event<arg_keyboard>	key_release; ///< a key is released while the window has focus. event code is event_code::key_release
 | 
				
			||||||
		basic_event<arg_keyboard>	key_char;    ///< a character, whitespace or backspace is pressed. event code is event_code::key_char
 | 
							basic_event<arg_keyboard>	key_char;	///< a character, whitespace or backspace is pressed. event code is event_code::key_char
 | 
				
			||||||
		basic_event<arg_keyboard>	shortkey;    ///< a defined short key is pressed. event code is event_code::shortkey
 | 
							basic_event<arg_keyboard>	shortkey;	///< a defined short key is pressed. event code is event_code::shortkey
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		basic_event<arg_move>		move;     ///< the window changes position
 | 
							basic_event<arg_move>		move;		///< the window changes position
 | 
				
			||||||
		basic_event<arg_resizing>	resizing; ///< the window is changing its size
 | 
							basic_event<arg_resizing>	resizing;	///< the window is changing its size
 | 
				
			||||||
		basic_event<arg_resized>	resized;  ///< the window is changing its size
 | 
							basic_event<arg_resized>	resized;	///< the window is changing its size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		basic_event<arg_destroy>	destroy;  ///< the window is destroyed, but occurs when all children have been destroyed
 | 
							basic_event<arg_destroy>	destroy;	///< the window is destroyed, but occurs when all children have been destroyed
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	namespace detail
 | 
						namespace detail
 | 
				
			||||||
 | 
				
			|||||||
@ -26,29 +26,38 @@ namespace nana{
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		struct implement;
 | 
							struct implement;
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
		group(	window    parent,         ///< 
 | 
							using field_reference = place::field_reference;
 | 
				
			||||||
				std::wstring    titel_ ={STR("")},     ///< 
 | 
					 | 
				
			||||||
				bool      format =false,  ///< Use a formated label?
 | 
					 | 
				
			||||||
				unsigned  gap =2,         ///< betwen the content  and the external limit
 | 
					 | 
				
			||||||
				rectangle r ={}           ///<
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// The default construction
 | 
				
			||||||
 | 
							group();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// The construction that creates the widget
 | 
				
			||||||
 | 
							group(window parent, const rectangle& = {}, bool visible = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/// The destruction
 | 
				
			||||||
		~group();
 | 
							~group();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							group& enable_format_caption(bool format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		place& get_place();
 | 
							place& get_place();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void collocate();
 | 
				
			||||||
 | 
							void div(const char* div_str);
 | 
				
			||||||
 | 
							field_reference operator[](const char* field);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		template<typename Widget, typename ...Args>
 | 
							template<typename Widget, typename ...Args>
 | 
				
			||||||
		Widget* create_child(const char* field, Args && ... args)
 | 
							Widget* create_child(const char* field, Args && ... args)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			auto wdg = new Widget(inner(), std::forward<Args>(args)...);
 | 
								auto wdg = new Widget(handle(), std::forward<Args>(args)...);
 | 
				
			||||||
			_m_add_child(field, wdg);
 | 
								_m_add_child(field, wdg);
 | 
				
			||||||
			return wdg;
 | 
								return wdg;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		window inner();
 | 
					 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		void _m_add_child(const char* field, widget*);
 | 
							void _m_add_child(const char* field, widget*);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void _m_complete_creation() override;
 | 
				
			||||||
		::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:
 | 
				
			||||||
 | 
				
			|||||||
@ -21,7 +21,7 @@
 | 
				
			|||||||
        #include <mutex>
 | 
					        #include <mutex>
 | 
				
			||||||
	#endif
 | 
						#endif
 | 
				
			||||||
	#include <map>
 | 
						#include <map>
 | 
				
			||||||
	#include <nana/paint/detail/image_ico.hpp>
 | 
						#include "../../paint/detail/image_ico.hpp"
 | 
				
			||||||
#elif defined(NANA_X11)
 | 
					#elif defined(NANA_X11)
 | 
				
			||||||
	#include <nana/system/platform.hpp>
 | 
						#include <nana/system/platform.hpp>
 | 
				
			||||||
	#include <nana/gui/detail/bedrock.hpp>
 | 
						#include <nana/gui/detail/bedrock.hpp>
 | 
				
			||||||
 | 
				
			|||||||
@ -23,76 +23,67 @@ namespace nana{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	struct group::implement
 | 
						struct group::implement
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		label			caption;
 | 
							label	caption;
 | 
				
			||||||
		panel<false>	content;
 | 
							place	place_content;
 | 
				
			||||||
		place place_outter;
 | 
					 | 
				
			||||||
		place place_content;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		implement(group* host):
 | 
							unsigned gap{2};
 | 
				
			||||||
			caption(*host),
 | 
					
 | 
				
			||||||
			content(*host),
 | 
							void create(window pnl)
 | 
				
			||||||
			place_outter(*host),
 | 
							{
 | 
				
			||||||
			place_content(content)
 | 
								caption.create(pnl);
 | 
				
			||||||
		{}
 | 
								place_content.bind(pnl);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	group::group(	window    parent,              ///<
 | 
						group::group()
 | 
				
			||||||
					std::wstring    titel_ /*={}*/,     ///<
 | 
							: impl_(new implement)
 | 
				
			||||||
					bool      format /*=false*/,  ///<
 | 
					 | 
				
			||||||
					unsigned  gap /*=2*/,         ///<
 | 
					 | 
				
			||||||
					rectangle r /*={} */          ///<
 | 
					 | 
				
			||||||
              )
 | 
					 | 
				
			||||||
			  :	panel (parent, r),
 | 
					 | 
				
			||||||
				impl_(new implement(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>";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		auto & outter = impl_->place_outter;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		outter.div(ft.str().c_str());
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		outter["titel"] << impl_->caption;
 | 
					 | 
				
			||||||
		outter["content"] << impl_->content;
 | 
					 | 
				
			||||||
		outter.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);
 | 
					 | 
				
			||||||
		impl_->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);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						group::group(window parent, const rectangle& r, bool vsb)
 | 
				
			||||||
 | 
							: group()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							create(parent, r, vsb);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	group::~group()
 | 
						group::~group()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						group& group::enable_format_caption(bool format)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							impl_->caption.format(format);
 | 
				
			||||||
 | 
							return *this;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	place& group::get_place()
 | 
						place& group::get_place()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return impl_->place_content;
 | 
							return impl_->place_content;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window group::inner()
 | 
					
 | 
				
			||||||
 | 
						void group::collocate()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return impl_->content;
 | 
							impl_->place_content.collocate();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void group::div(const char* div_str)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							::nana::size sz = impl_->caption.measure(1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							std::stringstream ss;
 | 
				
			||||||
 | 
							ss << "vert margin=[0," << impl_->gap << "," << impl_->gap << "," << impl_->gap << "]"
 | 
				
			||||||
 | 
								<< " <weight=" << sz.height << " <weight=5> <nanaGroupTitle2015 weight=" << sz.width + 1 << "> >"
 | 
				
			||||||
 | 
								<< " <"<<(div_str ? div_str : "")<<">";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							impl_->place_content.div(ss.str().c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						group::field_reference group::operator[](const char* field)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return impl_->place_content.field(field);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void group::_m_add_child(const char* field, widget* wdg)
 | 
						void group::_m_add_child(const char* field, widget* wdg)
 | 
				
			||||||
@ -100,6 +91,42 @@ namespace nana{
 | 
				
			|||||||
		impl_->place_content[field] << wdg->handle();
 | 
							impl_->place_content[field] << wdg->handle();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void group::_m_complete_creation()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							panel::_m_complete_creation();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							impl_->create(handle());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this->div(nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							auto & outter = impl_->place_content;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							outter["nanaGroupTitle2015"] << impl_->caption;
 | 
				
			||||||
 | 
							outter.collocate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							color pbg = API::bgcolor(this->parent());
 | 
				
			||||||
 | 
							impl_->caption.bgcolor(pbg.blend(colors::black, 0.975));
 | 
				
			||||||
 | 
							color bg = pbg.blend(colors::black, 0.950);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bgcolor(pbg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							drawing dw(*this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							::nana::size sz = impl_->caption.measure(1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
 | 
				
			||||||
 | 
							dw.draw([this, sz, bg, pbg](paint::graphics& graph)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								auto gap_px = impl_->gap - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								graph.rectangle(true, pbg);
 | 
				
			||||||
 | 
								graph.round_rectangle(rectangle(point(gap_px, sz.height / 2),
 | 
				
			||||||
 | 
									nana::size(graph.width() - 2 * gap_px, graph.height() - sz.height / 2 - gap_px)
 | 
				
			||||||
 | 
									),
 | 
				
			||||||
 | 
									3, 3, colors::gray_border, true, bg);
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	::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