image::paste may make a graphics if the graphics object is empty
This commit is contained in:
		
							parent
							
								
									13674fdc48
								
							
						
					
					
						commit
						358c0f662e
					
				@ -37,7 +37,7 @@ namespace nana{
 | 
				
			|||||||
		///  The construction that creates the widget and set the titel or caption
 | 
							///  The construction that creates the widget and set the titel or caption
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		group(window    parent,          ///< 
 | 
							group(window    parent,          ///< 
 | 
				
			||||||
			  string    titel_ /*= { STR("") }*/,     ///< 
 | 
								  ::nana::string    titel,     ///< 
 | 
				
			||||||
			  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 = {} ,          ///<
 | 
				
			||||||
@ -67,11 +67,10 @@ namespace nana{
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		void _m_add_child(const char* field, widget*);
 | 
							void _m_add_child(const char* field, widget*);
 | 
				
			||||||
 | 
							void _m_init();
 | 
				
			||||||
		void _m_complete_creation() override;
 | 
							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;
 | 
				
			||||||
		void init();
 | 
					 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		std::unique_ptr<implement> impl_;
 | 
							std::unique_ptr<implement> impl_;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
				
			|||||||
@ -28,20 +28,21 @@ namespace nana{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		unsigned gap{2};
 | 
							unsigned gap{2};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							implement() = default;
 | 
				
			||||||
 | 
							implement(window grp_panel, ::nana::string titel, bool vsb, unsigned gap=2)
 | 
				
			||||||
 | 
								: caption (grp_panel, std::move(titel), vsb),
 | 
				
			||||||
 | 
								  place_content{grp_panel},
 | 
				
			||||||
 | 
								  gap{gap}
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void create(window pnl)
 | 
							void create(window pnl)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			caption.create(pnl);
 | 
								caption.create(pnl);
 | 
				
			||||||
			caption.caption(STR(""));
 | 
								caption.caption(STR(""));
 | 
				
			||||||
			place_content.bind(pnl);
 | 
								place_content.bind(pnl);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		implement() = default;
 | 
					 | 
				
			||||||
		implement(window grp_panel, string titel, bool format, unsigned gap=2)
 | 
					 | 
				
			||||||
			: caption (grp_panel, std::move(titel), format),
 | 
					 | 
				
			||||||
			  place_content{grp_panel},
 | 
					 | 
				
			||||||
			  gap{gap}
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	group::group()
 | 
						group::group()
 | 
				
			||||||
@ -56,17 +57,17 @@ namespace nana{
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	group::group(	window    parent,              ///<
 | 
						group::group(	window    parent,              ///<
 | 
				
			||||||
					string    titel_   /*={}*/,     ///<
 | 
										::nana::string    titel   /*={}*/,     ///<
 | 
				
			||||||
					bool      format /*=false*/,  ///<
 | 
										bool      format /*=false*/,  ///<
 | 
				
			||||||
					unsigned  gap /*=2*/,         ///<
 | 
										unsigned  gap /*=2*/,         ///<
 | 
				
			||||||
					rectangle r /*={} */,          ///<
 | 
										rectangle r /*={} */,          ///<
 | 
				
			||||||
		            bool      vsb /*= true */        ///<
 | 
							            bool      vsb /*= true */        ///<
 | 
				
			||||||
					)
 | 
										)
 | 
				
			||||||
		: panel(parent, r, vsb),
 | 
							: panel(parent, r, vsb),
 | 
				
			||||||
		  impl_(new implement(*this, std::move(titel_), vsb))
 | 
							  impl_(new implement(*this, std::move(titel), vsb, gap))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		impl_->caption.format(format);
 | 
							impl_->caption.format(format);
 | 
				
			||||||
		init();
 | 
							_m_init();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -114,7 +115,7 @@ namespace nana{
 | 
				
			|||||||
		impl_->place_content[field] << wdg->handle();
 | 
							impl_->place_content[field] << wdg->handle();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void group::init()
 | 
						void group::_m_init()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this->div(nullptr);
 | 
							this->div(nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -153,7 +154,7 @@ namespace nana{
 | 
				
			|||||||
		impl_->create(handle());
 | 
							impl_->create(handle());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		init();
 | 
							_m_init();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	::nana::string group::_m_caption() const
 | 
						::nana::string group::_m_caption() const
 | 
				
			||||||
 | 
				
			|||||||
@ -263,38 +263,33 @@ namespace paint
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		void image::paste(graphics& dst, const point& p_dst) const
 | 
							void image::paste(graphics& dst, const point& p_dst) const
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if(image_ptr_ && !dst.empty())
 | 
								this->paste(rectangle{ this->size() }, dst, p_dst);
 | 
				
			||||||
				image_ptr_->paste(::nana::rectangle{ image_ptr_->size() }, dst, p_dst);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!image_ptr_)
 | 
					 | 
				
			||||||
				throw std::runtime_error("image is empty");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (dst.empty())
 | 
					 | 
				
			||||||
				throw std::invalid_argument("graphics is empty");
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void image::paste(const nana::rectangle& r_src, graphics & dst, const nana::point& p_dst) const
 | 
							void image::paste(const rectangle& r_src, graphics & dst, const point& p_dst) const
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (image_ptr_)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			if(image_ptr_ && !dst.empty())
 | 
					 | 
				
			||||||
				image_ptr_->paste(r_src, dst, p_dst);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!image_ptr_)
 | 
					 | 
				
			||||||
				throw std::runtime_error("image is empty");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (dst.empty())
 | 
									if (dst.empty())
 | 
				
			||||||
				throw std::invalid_argument("graphics is empty");
 | 
										dst.make({ r_src.width, r_src.height });	//throws if failed to create
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									image_ptr_->paste(r_src, dst, p_dst);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									throw std::runtime_error("image is empty");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void image::stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle & r_dst) const
 | 
							void image::stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle & r_dst) const
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if(image_ptr_ && !dst.empty())
 | 
								if (image_ptr_)
 | 
				
			||||||
				image_ptr_->stretch(r_src, dst, r_dst);
 | 
								{
 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!image_ptr_)
 | 
					 | 
				
			||||||
				throw std::runtime_error("image is empty");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (dst.empty())
 | 
									if (dst.empty())
 | 
				
			||||||
				throw std::invalid_argument("graphics is empty");
 | 
										dst.make({ r_src.width, r_src.height });	//throws if failed to create
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									image_ptr_->stretch(r_src, dst, r_dst);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									throw std::runtime_error("image is empty");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	//end class image
 | 
						//end class image
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user