add fit-content and improve place

This commit is contained in:
Jinhao
2017-02-05 08:37:16 +08:00
parent 2fd3aa5030
commit 2bd1cf715f
10 changed files with 1228 additions and 118 deletions

View File

@@ -1,7 +1,7 @@
/*
* A Label Control Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,8 +13,9 @@
*/
#include <nana/gui/widgets/label.hpp>
#include <nana/unicode_bidi.hpp>
#include <nana/gui/widgets/skeletons/text_token_stream.hpp>
#include <nana/gui/detail/widget_content_measurer_interface.hpp>
#include <nana/unicode_bidi.hpp>
#include <nana/system/platform.hpp>
#include <stdexcept>
#include <sstream>
@@ -80,14 +81,14 @@ namespace nana
{
traceable_.clear();
nana::paint::font ft = graph.typeface(); //used for restoring the font
auto pre_font = graph.typeface(); //used for restoring the font
const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
font_ = ft;
font_ = pre_font;
fblock_ = nullptr;
_m_set_default(ft, fgcolor);
_m_set_default(pre_font, fgcolor);
_m_measure(graph);
@@ -145,7 +146,7 @@ namespace nana
rs.pos.y += static_cast<int>(rs.pixels.back().pixels);
}
graph.typeface(ft);
graph.typeface(pre_font);
}
bool find(int x, int y, std::wstring& target, std::wstring& url) const
@@ -613,10 +614,13 @@ namespace nana
//class trigger
//@brief: Draw the label
struct trigger::impl_t
struct trigger::implement
{
class measurer;
widget * wd{nullptr};
paint::graphics * graph{nullptr};
class measurer * measurer{ nullptr };
align text_align{align::left};
align_v text_align_v;
@@ -643,8 +647,28 @@ namespace nana
std::vector<std::function<void(command, const std::string&)>> listener_;
};
class trigger::implement::measurer
: public dev::widget_content_measurer_interface
{
public:
measurer(implement* impl)
: impl_{ impl }
{}
optional<size> measure(bool limit_width, unsigned limit_pixels) const override
{
if (impl_->graph)
{
}
return{};
}
private:
implement * const impl_;
};
trigger::trigger()
:impl_(new impl_t)
:impl_(new implement)
{}
trigger::~trigger()
@@ -652,7 +676,7 @@ namespace nana
delete impl_;
}
trigger::impl_t * trigger::impl() const
trigger::implement * trigger::impl() const
{
return impl_;
}