refactor text_renderer

This commit is contained in:
Jinhao
2019-06-20 04:35:29 +08:00
parent ad4c3a3fc3
commit 8a0475c98c
9 changed files with 170 additions and 150 deletions

View File

@@ -1219,7 +1219,6 @@ namespace nana
unsigned min_column_width{ 20 }; ///< def=20 . non counting suspension_width
unsigned suspension_width{ 8 }; ///< def= . the trigger will set this to the width if ("...")
unsigned text_margin{ 5 }; ///< def= 5. Additional or extended with added (before) to the text width to determine the cell width. cell_w = text_w + ext_w +1
unsigned item_height_ex{ 6 }; ///< Set !=0 !!!! def=6. item_height = text_height + item_height_ex
@@ -1603,6 +1602,8 @@ the nana::detail::basic_window member pointer scheme
* It returns true to deselect the selected items. It returns false to cancel to deselect the selected items.
*/
void set_deselect(std::function<bool(nana::mouse)> predicate);
unsigned suspension_width() const;
private:
drawerbase::listbox::essence & _m_ess() const;
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const override;

View File

@@ -10,14 +10,20 @@ namespace nana
{
public:
using graph_reference = graphics &;
enum class mode
{
truncate_with_ellipsis,
truncate_letter_with_ellipsis,
word_wrap
};
text_renderer(graph_reference graph, align = align::left);
nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned restricted_pixels) const;
nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned space_pixels) const;
void render(const point&, const wchar_t*, std::size_t len);
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
void render(const point&, const wchar_t*, std::size_t len, unsigned restricted_pixels);
void render(const point&, const wchar_t*, std::size_t len, unsigned space_pixels, mode);
private:
graph_reference graph_;
align text_align_;