code review
This commit is contained in:
		
							parent
							
								
									6a93295bcf
								
							
						
					
					
						commit
						0e5c88f121
					
				@ -37,7 +37,6 @@ namespace drawerbase
 | 
				
			|||||||
		public:
 | 
							public:
 | 
				
			||||||
			implement * impl() const;
 | 
								implement * impl() const;
 | 
				
			||||||
		private:
 | 
							private:
 | 
				
			||||||
			void _m_draw(graph_reference);
 | 
					 | 
				
			||||||
			void _m_draw_background(graph_reference);
 | 
								void _m_draw_background(graph_reference);
 | 
				
			||||||
			void _m_draw_checkbox(graph_reference, unsigned first_line_height);
 | 
								void _m_draw_checkbox(graph_reference, unsigned first_line_height);
 | 
				
			||||||
			void _m_draw_title(graph_reference);
 | 
								void _m_draw_title(graph_reference);
 | 
				
			||||||
 | 
				
			|||||||
@ -45,7 +45,6 @@ namespace nana
 | 
				
			|||||||
				void week_name(unsigned index, const nana::string&);
 | 
									void week_name(unsigned index, const nana::string&);
 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				where _m_pos_where(graph_reference, const ::nana::point& pos);
 | 
									where _m_pos_where(graph_reference, const ::nana::point& pos);
 | 
				
			||||||
				void _m_draw(graph_reference);
 | 
					 | 
				
			||||||
				void _m_draw_topbar(graph_reference);
 | 
									void _m_draw_topbar(graph_reference);
 | 
				
			||||||
				void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
 | 
									void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
 | 
				
			||||||
				void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const nana::string&, bool primary, bool sel);
 | 
									void _m_draw_pos(drawing_basis &, graph_reference, int x, int y, const nana::string&, bool primary, bool sel);
 | 
				
			||||||
 | 
				
			|||||||
@ -67,7 +67,6 @@ namespace nana
 | 
				
			|||||||
				bool _m_close_menu();
 | 
									bool _m_close_menu();
 | 
				
			||||||
				std::size_t _m_item_by_pos(const ::nana::point&);
 | 
									std::size_t _m_item_by_pos(const ::nana::point&);
 | 
				
			||||||
				bool _m_track_mouse(const ::nana::point&);
 | 
									bool _m_track_mouse(const ::nana::point&);
 | 
				
			||||||
				void _m_draw();
 | 
					 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				widget *widget_;
 | 
									widget *widget_;
 | 
				
			||||||
				nana::paint::graphics	*graph_;
 | 
									nana::paint::graphics	*graph_;
 | 
				
			||||||
 | 
				
			|||||||
@ -36,7 +36,6 @@ namespace nana
 | 
				
			|||||||
				void attached(widget_reference, graph_reference)	override;
 | 
									void attached(widget_reference, graph_reference)	override;
 | 
				
			||||||
				void refresh(graph_reference)	override;
 | 
									void refresh(graph_reference)	override;
 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
				void _m_draw();
 | 
					 | 
				
			||||||
				void _m_draw_box(graph_reference);
 | 
									void _m_draw_box(graph_reference);
 | 
				
			||||||
				void _m_draw_progress(graph_reference);
 | 
									void _m_draw_progress(graph_reference);
 | 
				
			||||||
				bool _m_check_changing(unsigned) const;
 | 
									bool _m_check_changing(unsigned) const;
 | 
				
			||||||
 | 
				
			|||||||
@ -156,10 +156,10 @@ namespace nana
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					rectangle r{ graph.size() };
 | 
										rectangle r{ graph.size() };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					graph.rectangle(r, false, { 0xf0, 0xf0, 0xf0 });
 | 
										graph.rectangle(r, false, static_cast<color_rgb>(0xf0f0f0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					color lb(0x9d, 0xab, 0xb9);
 | 
										color lb(static_cast<color_rgb>(0x9dabb9));
 | 
				
			||||||
					color tr(0x48, 0x4e, 0x55);
 | 
										color tr(static_cast<color_rgb>(0x484e55));
 | 
				
			||||||
					graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb);
 | 
										graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			private:
 | 
								private:
 | 
				
			||||||
@ -168,7 +168,7 @@ namespace nana
 | 
				
			|||||||
					const unsigned half = (height - 2) / 2;
 | 
										const unsigned half = (height - 2) / 2;
 | 
				
			||||||
					int left = x + 1;
 | 
										int left = x + 1;
 | 
				
			||||||
					int top = y + 1;
 | 
										int top = y + 1;
 | 
				
			||||||
					nana::color clr_top(0xea, 0xea, 0xea), clr_bottom(0xdc, 0xdc, 0xdc);
 | 
										nana::color clr_top(static_cast<color_rgb>(0xEAEAEA)), clr_bottom(static_cast<color_rgb>(0xDCDCDC));
 | 
				
			||||||
					switch(state)
 | 
										switch(state)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
					case mouse_action::over:
 | 
										case mouse_action::over:
 | 
				
			||||||
@ -192,7 +192,7 @@ namespace nana
 | 
				
			|||||||
						int bottom = y + height - 1;
 | 
											int bottom = y + height - 1;
 | 
				
			||||||
						int right = x + width - 1;
 | 
											int right = x + width - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						graph.set_color(color(0x6e, 0x8d, 0x9f));
 | 
											graph.set_color(static_cast<color_rgb>(0x6E8D9F));
 | 
				
			||||||
						graph.line(point{ x, y }, point{right, y});
 | 
											graph.line(point{ x, y }, point{right, y});
 | 
				
			||||||
						graph.line(point{ x, y + 1 }, point{ x, bottom });
 | 
											graph.line(point{ x, y + 1 }, point{ x, bottom });
 | 
				
			||||||
						++x;
 | 
											++x;
 | 
				
			||||||
@ -207,8 +207,6 @@ namespace nana
 | 
				
			|||||||
				ui_element	ui_el_;
 | 
									ui_element	ui_el_;
 | 
				
			||||||
				struct style_tag
 | 
									struct style_tag
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					//nana::color_t bgcolor;
 | 
					 | 
				
			||||||
					//nana::color_t fgcolor;
 | 
					 | 
				
			||||||
					color bgcolor;
 | 
										color bgcolor;
 | 
				
			||||||
					color fgcolor;
 | 
										color fgcolor;
 | 
				
			||||||
				}style_;
 | 
									}style_;
 | 
				
			||||||
@ -217,8 +215,8 @@ namespace nana
 | 
				
			|||||||
			class tree_wrapper
 | 
								class tree_wrapper
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			public:
 | 
								public:
 | 
				
			||||||
				typedef widgets::detail::tree_cont<item_tag> container;
 | 
									using container = widgets::detail::tree_cont<item_tag>;
 | 
				
			||||||
				typedef container::node_type * node_handle;
 | 
									using node_handle = container::node_type*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				tree_wrapper()
 | 
									tree_wrapper()
 | 
				
			||||||
					:splitstr_(STR("\\")), cur_(nullptr)
 | 
										:splitstr_(STR("\\")), cur_(nullptr)
 | 
				
			||||||
@ -495,13 +493,12 @@ namespace nana
 | 
				
			|||||||
				bool erase_locate()
 | 
									bool erase_locate()
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ui_el_.index = npos;
 | 
										ui_el_.index = npos;
 | 
				
			||||||
					if(ui_el_.what != ui_el_.none)
 | 
										if(ui_el_.what == ui_el_.none)
 | 
				
			||||||
					{
 | 
											return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					ui_el_.what = ui_el_.none;
 | 
										ui_el_.what = ui_el_.none;
 | 
				
			||||||
					return true;
 | 
										return true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
					return false;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				ui_element locate() const
 | 
									ui_element locate() const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@ -528,13 +525,8 @@ namespace nana
 | 
				
			|||||||
					if(style_.mode != mode::floatlist)
 | 
										if(style_.mode != mode::floatlist)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						style_.state = mouse_action::normal;
 | 
											style_.state = mouse_action::normal;
 | 
				
			||||||
						switch(ui_el_.what)
 | 
											if (ui_element::item_name == ui_el_.what)
 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
						case ui_element::item_name:
 | 
					 | 
				
			||||||
							_m_selected(treebase_.tail(ui_el_.index));
 | 
												_m_selected(treebase_.tail(ui_el_.index));
 | 
				
			||||||
							break;
 | 
					 | 
				
			||||||
						default:	break;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -882,9 +874,8 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				void trigger::_m_event_agent_ready() const
 | 
									void trigger::_m_event_agent_ready() const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					auto & evt = scheme_->evt_holder();
 | 
					 | 
				
			||||||
					auto evt_agent = event_agent_.get();
 | 
										auto evt_agent = event_agent_.get();
 | 
				
			||||||
					evt.selected = [evt_agent](::nana::any& val){
 | 
										scheme_->evt_holder().selected = [evt_agent](::nana::any& val){
 | 
				
			||||||
						evt_agent->selected(val);
 | 
											evt_agent->selected(val);
 | 
				
			||||||
					};
 | 
										};
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
				
			|||||||
@ -48,29 +48,35 @@ namespace checkbox
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			void drawer::refresh(graph_reference graph)
 | 
								void drawer::refresh(graph_reference graph)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				_m_draw(graph);
 | 
									_m_draw_background(graph);
 | 
				
			||||||
 | 
									_m_draw_title(graph);
 | 
				
			||||||
 | 
									_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void drawer::mouse_down(graph_reference graph, const arg_mouse&)
 | 
								void drawer::mouse_down(graph_reference graph, const arg_mouse&)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				_m_draw(graph);
 | 
									refresh(graph);
 | 
				
			||||||
 | 
									API::lazy_refresh();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void drawer::mouse_up(graph_reference graph, const arg_mouse&)
 | 
								void drawer::mouse_up(graph_reference graph, const arg_mouse&)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if(impl_->react)
 | 
									if(impl_->react)
 | 
				
			||||||
					impl_->crook.reverse();
 | 
										impl_->crook.reverse();
 | 
				
			||||||
				_m_draw(graph);
 | 
									refresh(graph);
 | 
				
			||||||
 | 
									API::lazy_refresh();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void drawer::mouse_enter(graph_reference graph, const arg_mouse&)
 | 
								void drawer::mouse_enter(graph_reference graph, const arg_mouse&)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				_m_draw(graph);
 | 
									refresh(graph);
 | 
				
			||||||
 | 
									API::lazy_refresh();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void drawer::mouse_leave(graph_reference graph, const arg_mouse&)
 | 
								void drawer::mouse_leave(graph_reference graph, const arg_mouse&)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				_m_draw(graph);
 | 
									refresh(graph);
 | 
				
			||||||
 | 
									API::lazy_refresh();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			drawer::implement * drawer::impl() const
 | 
								drawer::implement * drawer::impl() const
 | 
				
			||||||
@ -78,6 +84,7 @@ namespace checkbox
 | 
				
			|||||||
				return impl_;
 | 
									return impl_;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								/*
 | 
				
			||||||
			void drawer::_m_draw(graph_reference graph)
 | 
								void drawer::_m_draw(graph_reference graph)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				_m_draw_background(graph);
 | 
									_m_draw_background(graph);
 | 
				
			||||||
@ -85,6 +92,7 @@ namespace checkbox
 | 
				
			|||||||
				_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2);
 | 
									_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2);
 | 
				
			||||||
				API::lazy_refresh();
 | 
									API::lazy_refresh();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void drawer::_m_draw_background(graph_reference graph)
 | 
								void drawer::_m_draw_background(graph_reference graph)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
 | 
				
			|||||||
@ -80,37 +80,6 @@ namespace nana
 | 
				
			|||||||
					return where::none;
 | 
										return where::none;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::_m_draw(graph_reference graph)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					const unsigned width = graph.width() - 2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					graph.rectangle(false, {0xb0, 0xb0, 0xb0});
 | 
					 | 
				
			||||||
					graph.rectangle({ 1, 1, width, static_cast<unsigned>(topbar_height) }, true, colors::white);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					_m_draw_topbar(graph);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if(graph.height() > 2 + topbar_height)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						nana::point refpos(1, static_cast<int>(topbar_height) + 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						nana::paint::graphics gbuf({ width, graph.height() - 2 - topbar_height });
 | 
					 | 
				
			||||||
						gbuf.rectangle(true, {0xf0, 0xf0, 0xf0});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						switch(page_)
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
						case page::date:
 | 
					 | 
				
			||||||
							_m_draw_days(refpos, gbuf);
 | 
					 | 
				
			||||||
							break;
 | 
					 | 
				
			||||||
						case page::month:
 | 
					 | 
				
			||||||
							_m_draw_months(refpos, gbuf);
 | 
					 | 
				
			||||||
							break;
 | 
					 | 
				
			||||||
						default:	break;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						graph.bitblt(refpos.x, refpos.y, gbuf);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				void trigger::_m_draw_topbar(graph_reference graph)
 | 
									void trigger::_m_draw_topbar(graph_reference graph)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					::nana::color arrow_bgcolor;
 | 
										::nana::color arrow_bgcolor;
 | 
				
			||||||
@ -455,7 +424,33 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				void trigger::refresh(graph_reference graph)
 | 
									void trigger::refresh(graph_reference graph)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					_m_draw(graph);
 | 
										const unsigned width = graph.width() - 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										graph.rectangle(false, { 0xb0, 0xb0, 0xb0 });
 | 
				
			||||||
 | 
										graph.rectangle({ 1, 1, width, static_cast<unsigned>(topbar_height) }, true, colors::white);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										_m_draw_topbar(graph);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (graph.height() > 2 + topbar_height)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											nana::point refpos(1, static_cast<int>(topbar_height)+1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											nana::paint::graphics gbuf({ width, graph.height() - 2 - topbar_height });
 | 
				
			||||||
 | 
											gbuf.rectangle(true, { 0xf0, 0xf0, 0xf0 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											switch (page_)
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
											case page::date:
 | 
				
			||||||
 | 
												_m_draw_days(refpos, gbuf);
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											case page::month:
 | 
				
			||||||
 | 
												_m_draw_months(refpos, gbuf);
 | 
				
			||||||
 | 
												break;
 | 
				
			||||||
 | 
											default:	break;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											graph.bitblt(refpos.x, refpos.y, gbuf);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::attached(widget_reference widget, graph_reference)
 | 
									void trigger::attached(widget_reference widget, graph_reference)
 | 
				
			||||||
@ -468,7 +463,7 @@ namespace nana
 | 
				
			|||||||
					where pos = _m_pos_where(graph, arg.pos);
 | 
										where pos = _m_pos_where(graph, arg.pos);
 | 
				
			||||||
					if(pos == pos_ && pos_ != where::textarea) return;
 | 
										if(pos == pos_ && pos_ != where::textarea) return;
 | 
				
			||||||
					pos_ = pos;
 | 
										pos_ = pos;
 | 
				
			||||||
					_m_draw(graph);
 | 
										refresh(graph);
 | 
				
			||||||
					API::lazy_refresh();
 | 
										API::lazy_refresh();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -476,7 +471,7 @@ namespace nana
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					if(where::none == pos_) return;
 | 
										if(where::none == pos_) return;
 | 
				
			||||||
					pos_ = where::none;
 | 
										pos_ = where::none;
 | 
				
			||||||
					_m_draw(graph);
 | 
										refresh(graph);
 | 
				
			||||||
					API::lazy_refresh();
 | 
										API::lazy_refresh();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -595,7 +590,7 @@ namespace nana
 | 
				
			|||||||
							nana::paint::graphics dirtybuf({ r.width, r.height });
 | 
												nana::paint::graphics dirtybuf({ r.width, r.height });
 | 
				
			||||||
							dirtybuf.bitblt(r, graph, refpos);
 | 
												dirtybuf.bitblt(r, graph, refpos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							_m_draw(graph);
 | 
												refresh(graph);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							nana::paint::graphics gbuf({ r.width, r.height });
 | 
												nana::paint::graphics gbuf({ r.width, r.height });
 | 
				
			||||||
							gbuf.bitblt(r, graph, refpos);
 | 
												gbuf.bitblt(r, graph, refpos);
 | 
				
			||||||
@ -603,7 +598,7 @@ namespace nana
 | 
				
			|||||||
							_m_perf_transform(tfid, graph, dirtybuf, gbuf, refpos);
 | 
												_m_perf_transform(tfid, graph, dirtybuf, gbuf, refpos);
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						else
 | 
											else
 | 
				
			||||||
							_m_draw(graph);
 | 
												refresh(graph);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
				
			|||||||
@ -858,13 +858,6 @@ namespace nana
 | 
				
			|||||||
					return &list_.back();
 | 
										return &list_.back();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                /// just append a list of new cat.
 | 
					 | 
				
			||||||
				void create_cat(const std::initializer_list<nana::string>& args)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					for (auto & arg : args)
 | 
					 | 
				
			||||||
						list_.emplace_back(arg);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		        /// will use the key to insert new cat before the first cat with compare less than the key, or at the end of the list of cat and return a ref to that new cat.  ?
 | 
							        /// will use the key to insert new cat before the first cat with compare less than the key, or at the end of the list of cat and return a ref to that new cat.  ?
 | 
				
			||||||
                category_t* create_cat(std::shared_ptr<nana::detail::key_interface> ptr)
 | 
					                category_t* create_cat(std::shared_ptr<nana::detail::key_interface> ptr)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
@ -1080,17 +1073,10 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				std::vector<cell>& get_cells(category_t * cat, size_type pos) const
 | 
									std::vector<cell>& get_cells(category_t * cat, size_type pos) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (!cat || pos >= cat->items.size())
 | 
										if (!cat)
 | 
				
			||||||
						throw std::out_of_range("nana::listbox: bad item position");
 | 
											throw std::out_of_range("nana::listbox: category is null");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					return cat->items[pos].cells;
 | 
										return cat->items.at(pos).cells;
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				nana::string text(category_t* cat, size_type pos, size_type col) const
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					if (pos < cat->items.size() && (col < cat->items[pos].cells.size()))
 | 
					 | 
				
			||||||
						return cat->items[pos].cells[col].text;
 | 
					 | 
				
			||||||
					return{};
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void text(category_t* cat, size_type pos, size_type col, cell&& cl, size_type columns)
 | 
									void text(category_t* cat, size_type pos, size_type col, cell&& cl, size_type columns)
 | 
				
			||||||
@ -3745,7 +3731,7 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				nana::string item_proxy::text(size_type col) const
 | 
									nana::string item_proxy::text(size_type col) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return ess_->lister.text(cat_, pos_.item, col);
 | 
										return ess_->lister.get_cells(cat_, pos_.item).at(col).text;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void item_proxy::icon(const nana::paint::image& img)
 | 
									void item_proxy::icon(const nana::paint::image& img)
 | 
				
			||||||
@ -3765,17 +3751,18 @@ namespace nana
 | 
				
			|||||||
				//Behavior of Iterator's value_type
 | 
									//Behavior of Iterator's value_type
 | 
				
			||||||
				bool item_proxy::operator==(const nana::string& s) const
 | 
									bool item_proxy::operator==(const nana::string& s) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return (ess_->lister.text(cat_, pos_.item, 0) == s);
 | 
										return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == s);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				bool item_proxy::operator==(const char * s) const
 | 
									bool item_proxy::operator==(const char * s) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return (ess_->lister.text(cat_, pos_.item, 0) == nana::string(nana::charset(s)));
 | 
										return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s)));
 | 
				
			||||||
 | 
										
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				bool item_proxy::operator==(const wchar_t * s) const
 | 
									bool item_proxy::operator==(const wchar_t * s) const
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					return (ess_->lister.text(cat_, pos_.item, 0) == nana::string(nana::charset(s)));
 | 
										return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s)));
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				item_proxy & item_proxy::operator=(const item_proxy& rhs)
 | 
									item_proxy & item_proxy::operator=(const item_proxy& rhs)
 | 
				
			||||||
@ -3792,10 +3779,9 @@ namespace nana
 | 
				
			|||||||
				// Behavior of Iterator
 | 
									// Behavior of Iterator
 | 
				
			||||||
				item_proxy & item_proxy::operator++()
 | 
									item_proxy & item_proxy::operator++()
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (++pos_.item < cat_->items.size())
 | 
										if (++pos_.item >= cat_->items.size())
 | 
				
			||||||
						return *this;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						cat_ = nullptr;
 | 
											cat_ = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					return *this;
 | 
										return *this;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3916,8 +3902,7 @@ namespace nana
 | 
				
			|||||||
                    for (item_proxy &it : *this )
 | 
					                    for (item_proxy &it : *this )
 | 
				
			||||||
                        it.select(sel);
 | 
					                        it.select(sel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    ess_->lister.last_selected_abs = 
 | 
					                    ess_->lister.last_selected_abs = ess_->lister.last_selected_dpl =  index_pair {this->pos_, npos};
 | 
				
			||||||
                    ess_->lister.last_selected_dpl =  index_pair {this->pos_, npos};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return *this;
 | 
					                    return *this;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -4232,7 +4217,9 @@ namespace nana
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			internal_scope_guard lock;
 | 
								internal_scope_guard lock;
 | 
				
			||||||
			auto & ess = _m_ess();
 | 
								auto & ess = _m_ess();
 | 
				
			||||||
			ess.lister.create_cat(args);
 | 
					
 | 
				
			||||||
 | 
								for (auto & arg : args)
 | 
				
			||||||
 | 
									ess.lister.create_cat(nana::string{ arg });
 | 
				
			||||||
			ess.update();
 | 
								ess.update();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -148,7 +148,7 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
					auto pos = items_->cont().size();
 | 
										auto pos = items_->cont().size();
 | 
				
			||||||
					items_->append(text, shkey);
 | 
										items_->append(text, shkey);
 | 
				
			||||||
					_m_draw();
 | 
										refresh(*graph_);
 | 
				
			||||||
					API::update_window(*widget_);
 | 
										API::update_window(*widget_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					return at(pos);
 | 
										return at(pos);
 | 
				
			||||||
@ -173,13 +173,65 @@ namespace nana
 | 
				
			|||||||
					widget_ = &widget;
 | 
										widget_ = &widget;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::refresh(graph_reference)
 | 
									void trigger::refresh(graph_reference graph)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					_m_draw();
 | 
										auto bgcolor = API::bgcolor(*widget_);
 | 
				
			||||||
					API::lazy_refresh();
 | 
										graph_->rectangle(true, bgcolor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										item_renderer ird(*widget_, graph);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										nana::point item_pos(2, 2);
 | 
				
			||||||
 | 
										nana::size item_s(0, 23);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										unsigned long index = 0;
 | 
				
			||||||
 | 
										for (auto i : items_->cont())
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											//Transform the text if it contains the hotkey character
 | 
				
			||||||
 | 
											::nana::char_t hotkey;
 | 
				
			||||||
 | 
											::nana::string::size_type hotkey_pos;
 | 
				
			||||||
 | 
											auto text = API::transform_shortkey_text(i->text, hotkey, &hotkey_pos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											nana::size text_s = graph.text_extent_size(text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											item_s.width = text_s.width + 16;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											i->pos = item_pos;
 | 
				
			||||||
 | 
											i->size = item_s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											using state = item_renderer::state;
 | 
				
			||||||
 | 
											state item_state = (index != state_.active ? state::normal : (state_.menu_active ? state::selected : state::highlighted));
 | 
				
			||||||
 | 
											ird.background(item_pos, item_s, item_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if (state::selected == item_state)
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												int x = item_pos.x + item_s.width;
 | 
				
			||||||
 | 
												int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1;
 | 
				
			||||||
 | 
												graph.line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.4));
 | 
				
			||||||
 | 
												graph.line({ x + 1, y1 }, { x + 1, y2 }, bgcolor.blend(colors::button_face_shadow_end, 0.5));
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::mouse_move(graph_reference, const arg_mouse& arg)
 | 
											//Draw text, the text is transformed from orignal for hotkey character
 | 
				
			||||||
 | 
											int text_top_off = (item_s.height - text_s.height) / 2;
 | 
				
			||||||
 | 
											ird.caption({ item_pos.x + 8, item_pos.y + text_top_off }, text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if (hotkey)
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												unsigned off_w = (hotkey_pos ? graph.text_extent_size(text, static_cast<unsigned>(hotkey_pos)).width : 0);
 | 
				
			||||||
 | 
												nana::size hotkey_size = graph.text_extent_size(text.c_str() + hotkey_pos, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
												unsigned ascent, descent, inleading;
 | 
				
			||||||
 | 
												graph.text_metrics(ascent, descent, inleading);
 | 
				
			||||||
 | 
												int x = item_pos.x + 8 + off_w;
 | 
				
			||||||
 | 
												int y = item_pos.y + text_top_off + ascent + 1;
 | 
				
			||||||
 | 
												graph.line({ x, y }, { x + static_cast<int>(hotkey_size.width) - 1, y }, ::nana::colors::black);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											item_pos.x += i->size.width;
 | 
				
			||||||
 | 
											++index;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									void trigger::mouse_move(graph_reference graph, const arg_mouse& arg)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if (arg.pos != state_.mouse_pos)
 | 
										if (arg.pos != state_.mouse_pos)
 | 
				
			||||||
						state_.nullify_mouse = false;
 | 
											state_.nullify_mouse = false;
 | 
				
			||||||
@ -200,7 +252,7 @@ namespace nana
 | 
				
			|||||||
					if(popup)
 | 
										if(popup)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						_m_popup_menu();
 | 
											_m_popup_menu();
 | 
				
			||||||
						_m_draw();
 | 
											refresh(graph);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -228,7 +280,7 @@ namespace nana
 | 
				
			|||||||
					else
 | 
										else
 | 
				
			||||||
						_m_total_close();
 | 
											_m_total_close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					_m_draw();
 | 
										refresh(graph);
 | 
				
			||||||
					API::lazy_refresh();
 | 
										API::lazy_refresh();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -245,12 +297,12 @@ namespace nana
 | 
				
			|||||||
					{
 | 
										{
 | 
				
			||||||
						state_.behavior = state_.behavior_none;
 | 
											state_.behavior = state_.behavior_none;
 | 
				
			||||||
						_m_total_close();
 | 
											_m_total_close();
 | 
				
			||||||
						_m_draw();
 | 
											refresh(graph);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::focus(graph_reference, const arg_focus& arg)
 | 
									void trigger::focus(graph_reference graph, const arg_focus& arg)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if((arg.getting == false) && (state_.active != npos))
 | 
										if((arg.getting == false) && (state_.active != npos))
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
@ -259,12 +311,12 @@ namespace nana
 | 
				
			|||||||
						state_.menu_active = false;
 | 
											state_.menu_active = false;
 | 
				
			||||||
						_m_close_menu();
 | 
											_m_close_menu();
 | 
				
			||||||
						state_.active = npos;
 | 
											state_.active = npos;
 | 
				
			||||||
						_m_draw();
 | 
											refresh(graph);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::key_press(graph_reference, const arg_keyboard& arg)
 | 
									void trigger::key_press(graph_reference graph, const arg_keyboard& arg)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					state_.nullify_mouse = true;
 | 
										state_.nullify_mouse = true;
 | 
				
			||||||
					if(state_.menu)
 | 
										if(state_.menu)
 | 
				
			||||||
@ -354,11 +406,11 @@ namespace nana
 | 
				
			|||||||
						}
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					_m_draw();
 | 
										refresh(graph);
 | 
				
			||||||
					API::lazy_refresh();
 | 
										API::lazy_refresh();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void trigger::key_release(graph_reference, const arg_keyboard& arg)
 | 
									void trigger::key_release(graph_reference graph, const arg_keyboard& arg)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if(arg.key == 18)
 | 
										if(arg.key == 18)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
@ -376,7 +428,7 @@ namespace nana
 | 
				
			|||||||
						}
 | 
											}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						state_.menu_active = false;
 | 
											state_.menu_active = false;
 | 
				
			||||||
						_m_draw();
 | 
											refresh(graph);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@ -396,7 +448,7 @@ namespace nana
 | 
				
			|||||||
						if(_m_popup_menu())
 | 
											if(_m_popup_menu())
 | 
				
			||||||
							state_.menu->goto_next(true);
 | 
												state_.menu->goto_next(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						_m_draw();
 | 
											refresh(graph);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
						state_.behavior = state_.behavior_menu;
 | 
											state_.behavior = state_.behavior_menu;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
@ -424,7 +476,7 @@ namespace nana
 | 
				
			|||||||
					if(index != state_.active)
 | 
										if(index != state_.active)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						state_.active = index;
 | 
											state_.active = index;
 | 
				
			||||||
						_m_draw();
 | 
											refresh(*graph_);
 | 
				
			||||||
						API::lazy_refresh();
 | 
											API::lazy_refresh();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if(_m_popup_menu())
 | 
											if(_m_popup_menu())
 | 
				
			||||||
@ -456,7 +508,7 @@ namespace nana
 | 
				
			|||||||
							{
 | 
												{
 | 
				
			||||||
								_m_total_close();
 | 
													_m_total_close();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
								_m_draw();
 | 
													refresh(*graph_);
 | 
				
			||||||
								API::update_window(widget_->handle());
 | 
													API::update_window(widget_->handle());
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						});
 | 
											});
 | 
				
			||||||
@ -526,6 +578,7 @@ namespace nana
 | 
				
			|||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									/*
 | 
				
			||||||
				void trigger::_m_draw()
 | 
									void trigger::_m_draw()
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					auto bgcolor = API::bgcolor(*widget_);
 | 
										auto bgcolor = API::bgcolor(*widget_);
 | 
				
			||||||
@ -583,6 +636,7 @@ namespace nana
 | 
				
			|||||||
						++index;
 | 
											++index;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//struct state_type
 | 
									//struct state_type
 | 
				
			||||||
					trigger::state_type::state_type()
 | 
										trigger::state_type::state_type()
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ namespace nana
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				if(_m_check_changing(value_))
 | 
									if(_m_check_changing(value_))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					_m_draw();
 | 
										refresh(*graph_);
 | 
				
			||||||
					API::update_window(widget_->handle());
 | 
										API::update_window(widget_->handle());
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return v;
 | 
									return v;
 | 
				
			||||||
@ -99,18 +99,13 @@ namespace nana
 | 
				
			|||||||
				return s;
 | 
									return s;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void trigger::refresh(graph_reference)
 | 
								void trigger::refresh(graph_reference graph)
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				_m_draw();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			void trigger::_m_draw()
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (false == unknown_)
 | 
									if (false == unknown_)
 | 
				
			||||||
					draw_width_ = static_cast<unsigned>((graph_->width() - border * 2) * (double(value_) / max_));
 | 
										draw_width_ = static_cast<unsigned>((graph.width() - border * 2) * (double(value_) / max_));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				_m_draw_box(*graph_);
 | 
									_m_draw_box(graph);
 | 
				
			||||||
				_m_draw_progress(*graph_);
 | 
									_m_draw_progress(graph);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void trigger::_m_draw_box(graph_reference graph)
 | 
								void trigger::_m_draw_box(graph_reference graph)
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ namespace nana
 | 
				
			|||||||
		//Here defines some function objects
 | 
							//Here defines some function objects
 | 
				
			||||||
		namespace treebox
 | 
							namespace treebox
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			typedef trigger::node_type node_type;
 | 
								using node_type = trigger::node_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len)
 | 
								bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@ -78,7 +78,7 @@ namespace nana
 | 
				
			|||||||
				: public drawer_trigger, public compset_interface
 | 
									: public drawer_trigger, public compset_interface
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
			public:
 | 
								public:
 | 
				
			||||||
				typedef drawer_trigger::graph_reference graph_reference;
 | 
									using graph_reference = drawer_trigger::graph_reference;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
 | 
									void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user