improve inputbox
This commit is contained in:
		
							parent
							
								
									022f7168c0
								
							
						
					
					
						commit
						f454a965be
					
				@ -183,10 +183,28 @@ namespace nana
 | 
			
		||||
			std::unique_ptr<implement> impl_;
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		class path
 | 
			
		||||
			: public abstract_content
 | 
			
		||||
		{
 | 
			
		||||
			struct implement;
 | 
			
		||||
		public:
 | 
			
		||||
			path(::nana::string label, ::nana::string init_path = ::nana::string());
 | 
			
		||||
			~path();
 | 
			
		||||
 | 
			
		||||
			::nana::string value() const;
 | 
			
		||||
		private:
 | 
			
		||||
			//Implementation of abstract_content
 | 
			
		||||
			const ::nana::string& label() const override;
 | 
			
		||||
			window create(window, unsigned label_px) override;
 | 
			
		||||
			unsigned fixed_pixels() const override;
 | 
			
		||||
		private:
 | 
			
		||||
			std::unique_ptr<implement> impl_;
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		inputbox(window, ::nana::string description, ::nana::string title = ::nana::string());
 | 
			
		||||
 | 
			
		||||
		void image(::nana::paint::image, bool is_left);
 | 
			
		||||
		void image_v(::nana::paint::image, bool is_top);
 | 
			
		||||
		void image(::nana::paint::image, bool is_left, const rectangle& valid_area = {});
 | 
			
		||||
		void image_v(::nana::paint::image, bool is_top, const rectangle& valid_area = {});
 | 
			
		||||
 | 
			
		||||
		template<typename ...Args>
 | 
			
		||||
		bool show(Args&& ... args)
 | 
			
		||||
@ -231,6 +249,7 @@ namespace nana
 | 
			
		||||
		::nana::string title_;
 | 
			
		||||
		std::function<bool(window)> verifier_;
 | 
			
		||||
		::nana::paint::image images_[4];
 | 
			
		||||
		::nana::rectangle valid_areas_[4];
 | 
			
		||||
	};
 | 
			
		||||
}//end namespace nana
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ namespace nana
 | 
			
		||||
		: public widget_object<category::widget_tag, drawerbase::picture::drawer>
 | 
			
		||||
	{
 | 
			
		||||
	public:
 | 
			
		||||
		picture();
 | 
			
		||||
		picture() = default;
 | 
			
		||||
		picture(window, bool visible);
 | 
			
		||||
		picture(window, const rectangle& ={}, bool visible = true);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -475,7 +475,7 @@ namespace nana
 | 
			
		||||
		: public ::nana::form
 | 
			
		||||
	{
 | 
			
		||||
	public:
 | 
			
		||||
		inputbox_window(window owner, paint::image (&imgs)[4], const ::nana::string & desc, const ::nana::string& title, std::size_t contents, unsigned fixed_pixels, const std::vector<unsigned>& each_height)
 | 
			
		||||
		inputbox_window(window owner, paint::image (&imgs)[4], ::nana::rectangle (&valid_areas)[4], const ::nana::string & desc, const ::nana::string& title, std::size_t contents, unsigned fixed_pixels, const std::vector<unsigned>& each_height)
 | 
			
		||||
			: form(owner, API::make_center(owner, 500, 300), appear::decorate<>())
 | 
			
		||||
		{
 | 
			
		||||
			desc_.create(*this);
 | 
			
		||||
@ -532,6 +532,12 @@ namespace nana
 | 
			
		||||
			if (imgs[2])	//Left
 | 
			
		||||
			{
 | 
			
		||||
				auto & sz = img_sz[2];
 | 
			
		||||
				if (!valid_areas[2].empty())
 | 
			
		||||
				{
 | 
			
		||||
					sz.width = valid_areas[2].width;
 | 
			
		||||
					sz.height = valid_areas[2].height;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					sz = imgs[2].size();
 | 
			
		||||
				sz.width = static_cast<size::value_type>(double(sz.width) * (double(height) / double(sz.height)));
 | 
			
		||||
				desc_extent.width += sz.width;
 | 
			
		||||
@ -540,6 +546,12 @@ namespace nana
 | 
			
		||||
			if (imgs[3])	//Right
 | 
			
		||||
			{
 | 
			
		||||
				auto & sz = img_sz[3];
 | 
			
		||||
				if (!valid_areas[3].empty())
 | 
			
		||||
				{
 | 
			
		||||
					sz.width = valid_areas[3].width;
 | 
			
		||||
					sz.height = valid_areas[3].height;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					sz = imgs[3].size();
 | 
			
		||||
				sz.width = static_cast<size::value_type>(double(sz.width) * (double(height) / double(sz.height)));
 | 
			
		||||
				desc_extent.width += sz.width;
 | 
			
		||||
@ -548,6 +560,12 @@ namespace nana
 | 
			
		||||
			if (imgs[0])	//Top
 | 
			
		||||
			{
 | 
			
		||||
				auto & sz = img_sz[0];
 | 
			
		||||
				if (!valid_areas[0].empty())
 | 
			
		||||
				{
 | 
			
		||||
					sz.width = valid_areas[0].width;
 | 
			
		||||
					sz.height = valid_areas[0].height;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					sz = imgs[0].size();
 | 
			
		||||
				sz.height = static_cast<size::value_type>(double(sz.height) * (double(desc_extent.width) / double(sz.width)));
 | 
			
		||||
				height += sz.height;
 | 
			
		||||
@ -556,6 +574,12 @@ namespace nana
 | 
			
		||||
			if (imgs[1])	//Bottom
 | 
			
		||||
			{
 | 
			
		||||
				auto & sz = img_sz[1];
 | 
			
		||||
				if (!valid_areas[1].empty())
 | 
			
		||||
				{
 | 
			
		||||
					sz.width = valid_areas[1].width;
 | 
			
		||||
					sz.height = valid_areas[1].height;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
					sz = imgs[1].size();
 | 
			
		||||
				sz.height = static_cast<size::value_type>(double(sz.height) * (double(desc_extent.width) / double(sz.width)));
 | 
			
		||||
				height += sz.height;
 | 
			
		||||
@ -575,8 +599,7 @@ namespace nana
 | 
			
		||||
				if (imgs[i])
 | 
			
		||||
				{
 | 
			
		||||
					images_[i].create(*this, true);
 | 
			
		||||
					images_[i].load(imgs[i]);
 | 
			
		||||
					//images_[i].bgstyle(true, ::nana::arrange::horizontal_vertical, 0, 0);
 | 
			
		||||
					images_[i].load(imgs[i], valid_areas[i]);
 | 
			
		||||
					images_[i].stretchable(0, 0, 0, 0);
 | 
			
		||||
					place_[img_fields[i]] << images_[i];
 | 
			
		||||
					place_.field_display(img_fields[i], true);
 | 
			
		||||
@ -1030,16 +1053,18 @@ namespace nana
 | 
			
		||||
			title_(std::move(title))
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	void inputbox::image(::nana::paint::image img, bool is_left)
 | 
			
		||||
	void inputbox::image(::nana::paint::image img, bool is_left, const rectangle& valid_area)
 | 
			
		||||
	{
 | 
			
		||||
		auto pos = (is_left ? 2 : 3);
 | 
			
		||||
		images_[pos] = std::move(img);
 | 
			
		||||
		valid_areas_[pos] = valid_area;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void inputbox::image_v(::nana::paint::image img, bool is_top)
 | 
			
		||||
	void inputbox::image_v(::nana::paint::image img, bool is_top, const rectangle& valid_area)
 | 
			
		||||
	{
 | 
			
		||||
		auto pos = (is_top ? 0 : 1);
 | 
			
		||||
		images_[pos] = std::move(img);
 | 
			
		||||
		valid_areas_[pos] = valid_area;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void inputbox::verify(std::function<bool(window)> verifier)
 | 
			
		||||
@ -1068,7 +1093,7 @@ namespace nana
 | 
			
		||||
			each_pixels.push_back(px.height);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		inputbox_window input_wd(owner_, images_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
 | 
			
		||||
		inputbox_window input_wd(owner_, images_, valid_areas_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
 | 
			
		||||
 | 
			
		||||
		std::vector<window> inputs;
 | 
			
		||||
		for (auto p : contents)
 | 
			
		||||
 | 
			
		||||
@ -80,7 +80,6 @@ namespace nana
 | 
			
		||||
					if (backimg.stretchable)
 | 
			
		||||
					{
 | 
			
		||||
						auto fit_size = fit_zoom({ valid_area.width, valid_area.height }, graphsize);
 | 
			
		||||
						//::nana::point pos{ int(graphsize.width - fit_size.width), int(graphsize.height - fit_size.height) };
 | 
			
		||||
						::nana::point pos;
 | 
			
		||||
 | 
			
		||||
						if (fit_size.width != graphsize.width)
 | 
			
		||||
@ -176,8 +175,6 @@ namespace nana
 | 
			
		||||
	}//end namespace drawerbase
 | 
			
		||||
 | 
			
		||||
	//class picture
 | 
			
		||||
		picture::picture(){}
 | 
			
		||||
 | 
			
		||||
		picture::picture(window wd, bool visible)
 | 
			
		||||
		{
 | 
			
		||||
			create(wd, rectangle(), visible);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user