remove paint::gadget

This commit is contained in:
Jinhao
2015-08-20 01:09:29 +08:00
parent 4323977908
commit 42443dcafd
27 changed files with 1024 additions and 763 deletions

View File

@@ -542,32 +542,6 @@ namespace nana{
return false;
}
/*
bool native_interface::window_icon(native_window_type wd, const paint::image& big_icon, const paint::image& small_icon) //deprecated
{
#if defined(NANA_WINDOWS)
HICON h_big_icon = paint::image_accessor::icon(big_icon);
HICON h_small_icon = paint::image_accessor::icon(small_icon);
if (h_big_icon || h_small_icon)
{
nana::detail::platform_spec::instance().keep_window_icon(wd, (!big_icon.empty() ? big_icon : small_icon));
if (h_big_icon) {
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(h_big_icon));
}
if (h_small_icon) {
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_SMALL, reinterpret_cast<WPARAM>(h_small_icon));
}
return true;
}
#elif defined(NANA_X11)
return window_icon(wd, big_icon);
#endif
return false;
}
*/
void native_interface::activate_owner(native_window_type wd)
{
#if defined(NANA_WINDOWS)

View File

@@ -272,7 +272,7 @@ namespace nana
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, unsigned weight)
{
graph.rectangle(r, false, static_cast<color_rgb>((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E));
graph.rectangle(::nana::rectangle{r}.pare_off(1), false, bgcolor);
graph.rectangle(::nana::rectangle(r).pare_off(1), false, bgcolor);
return true;
}
};
@@ -601,8 +601,7 @@ namespace nana
: nana::noncopyable, nana::nonmovable
{
using element_type = ElementInterface;
using factory_interface = pat::cloneable<element::provider::factory_interface<element_type>>; //deprecated
//using factory_interface = pat::cloneable<element::detail::factory_abstract>;
using factory_interface = pat::cloneable<element::detail::factory_abstract>;
public:
~element_object()
@@ -617,8 +616,7 @@ namespace nana
auto keep_e = element_ptr_;
factory_ = rhs;
element_ptr_ = factory_->create(); //deprecated
//element_ptr_ = static_cast<element_type*>(static_cast<element::provider::factory_interface<element_type>&>(*factory_).create());
element_ptr_ = static_cast<element_type*>(static_cast<element::provider::factory_interface<element_type>&>(*factory_).create());
if(nullptr == factory_ || nullptr == element_ptr_)
{
@@ -647,14 +645,6 @@ namespace nana
class element_manager
: nana::noncopyable, nana::nonmovable
{
/*
template<typename ElementInterface> //deprecated
struct item
{
element_object<ElementInterface> * employee;
std::map<std::string, std::shared_ptr<element_object<ElementInterface>>> table;
};
*/
template<typename ElementInterface>
struct item
{

View File

@@ -959,7 +959,7 @@ namespace nana
int inputbox::date::month() const
{
if (!impl_->wdg_month.empty())
return impl_->wdg_month.option() + 1;
return static_cast<int>(impl_->wdg_month.option()) + 1;
return impl_->month;
}
@@ -1028,7 +1028,7 @@ namespace nana
impl->wdg_day.events().destroy.connect_unignorable([impl]
{
impl->day = impl->wdg_day.to_int();
impl->month = impl->wdg_month.option() + 1;
impl->month = static_cast<int>(impl->wdg_month.option()) + 1;
});
impl->wdg_year.events().destroy.connect_unignorable([impl]
@@ -1040,7 +1040,7 @@ namespace nana
{
auto month = impl->wdg_month.option() + 1;
auto year = impl->wdg_year.to_int();
int days = ::nana::date::month_days(year, month);
int days = ::nana::date::month_days(year, static_cast<unsigned>(month));
auto day = impl->wdg_day.to_int();
impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day

View File

@@ -24,6 +24,8 @@
#include <memory>
#include <limits> //numeric_limits
#include <cstdlib> //std::abs
#include <cstring> //std::memset
#include "place_parts.hpp"
@@ -93,7 +95,13 @@ namespace nana
std::string pos_str() const
{
#ifdef NANA_MINGW
std::stringstream ss;
ss<<pos();
return ss.str();
#else
return std::to_string(pos());
#endif // NANA_MINGW
}
token read()
@@ -731,7 +739,7 @@ namespace nana
return child.get();
}
return nullptr;
}
public:
void _m_visible_for_child(division * div, bool vsb)
@@ -1397,7 +1405,6 @@ namespace nana
else if (left_px < 0)
left_px = 0;
auto leaf_left = _m_leaf_left();
double imd_rate = 100.0 / area_px;
left_px = static_cast<int>(limit_px(_m_leaf_left(), left_px, area_px));
_m_leaf_left()->weight.assign_percent(imd_rate * left_px);
@@ -1692,7 +1699,6 @@ namespace nana
});
//indicator_.dock_area->z_order(nullptr, ::nana::z_order_action::top); //deprecated
API::bring_top(indicator_.dock_area->handle(), false);
indicator_.dock_area->show();
}
@@ -2112,7 +2118,6 @@ namespace nana
}
field_gather * attached_field = nullptr;
field_dock* attached_dock = nullptr;
if (name.size())
{
//find the field with specified name.
@@ -2154,11 +2159,6 @@ namespace nana
}
break;
case token::dock:
//deprecated
//
//if (name.empty())
// throw std::invalid_argument("nana.place: dock must have a name.");
div.reset(new div_dock(std::move(name), this));
break;
default:
@@ -2258,7 +2258,7 @@ namespace nana
check_fn(div);
}
//connect the field/dock with div object,
//connect the field/dock with div object,
void place::implement::connect(division* start)
{
if (!start)
@@ -2307,7 +2307,7 @@ namespace nana
div->field->attached = div;
}
}
}
for (auto & child : div->children)
@@ -2392,33 +2392,6 @@ namespace nana
//if name violate the naming convention.
place_parts::check_field_name(name);
/* //deprecated
implement::division * div_ptr = nullptr;
implement::field_gather * field_ptr = nullptr;
{
auto i = impl_->fields.find(name);
if (i != impl_->fields.end())
field_ptr = i->second;
}
if (field_ptr)
{
//remove the existing div object
div_ptr = field_ptr->attached;
}
else
div_ptr = impl_->search_div_name(impl_->root_division.get(), name);
if (nullptr == div_ptr)
{
std::string what = "nana::place: field '";
what += name;
what += "' is not found.";
throw std::invalid_argument(what);
}
*/
auto div_ptr = impl_->search_div_name(impl_->root_division.get(), name);
if (!div_ptr)
{
@@ -2434,7 +2407,6 @@ namespace nana
implement::division * div_owner = div_ptr->div_owner;
implement::division * div_next = div_ptr->div_next;
implement::division * div_bro = nullptr;
if (div_owner)
{
for (auto i = div_owner->children.begin(); i != div_owner->children.end(); ++i)
@@ -2444,7 +2416,6 @@ namespace nana
replaced = &(*i);
break;
}
div_bro = i->get();
}
}
else
@@ -2458,7 +2429,6 @@ namespace nana
auto modified = impl_->scan_div(tknizer);
auto modified_ptr = modified.get();
modified_ptr->name = name;
//modified_ptr->field = field_ptr;
replaced->swap(modified);
@@ -2468,33 +2438,6 @@ namespace nana
modified_ptr->div_owner = div_owner;
modified_ptr->div_next = div_next;
//if (field_ptr)
// field_ptr->attached = modified_ptr;
/*
std::function<void(implement::division*)> attach;
attach = [this, &attach](implement::division* div)
{
if (!div->name.empty())
{
auto i = impl_->fields.find(div->name);
if (impl_->fields.end() != i)
{
if (i->second->attached != div)
{
i->second->attached = div;
div->field = i->second;
}
}
}
for (auto& child : div->children)
{
attach(child.get());
}
};
attach(impl_->root_division.get());
*/
}
catch (...)
{
@@ -2538,7 +2481,7 @@ namespace nana
void place::field_visible(const char* name, bool vsb)
{
if (!name) name = "";
//May throw std::invalid_argument
place_parts::check_field_name(name);

View File

@@ -14,7 +14,6 @@
#include <nana/gui/widgets/categorize.hpp>
#include <nana/gui/widgets/float_listbox.hpp>
#include <nana/gui/element.hpp>
//#include <nana/paint/gadget.hpp> //deprecated
#include <nana/gui/widgets/detail/tree_cont.hpp>
#include <stdexcept>

View File

@@ -11,7 +11,6 @@
*/
#include <nana/gui/widgets/checkbox.hpp>
//#include <nana/paint/gadget.hpp> //deprecated
#include <nana/paint/text_renderer.hpp>
#include <nana/gui/element.hpp>
#include <algorithm>

View File

@@ -12,7 +12,6 @@
#include <nana/gui/widgets/date_chooser.hpp>
#include <nana/gui/element.hpp>
//#include <nana/paint/gadget.hpp> //deprecated
#include <nana/system/platform.hpp>
#include <sstream>

View File

@@ -12,7 +12,6 @@
#include <nana/gui/widgets/menu.hpp>
#include <nana/system/platform.hpp>
#include <nana/paint/gadget.hpp>
#include <nana/gui/element.hpp>
#include <nana/gui/wvl.hpp>
#include <nana/paint/text_renderer.hpp>

View File

@@ -2250,7 +2250,7 @@ namespace nana{ namespace widgets
break;
case keyboard::os_end:
if (caret.y != nlines - 1) {
caret.y = nlines - 1;
caret.y = static_cast<decltype(caret.y)>(nlines - 1);
changed = true;
}
break;
@@ -2265,7 +2265,7 @@ namespace nana{ namespace widgets
}else {
if (caret.y != 0) {
--caret.y;
caret.x = textbase_.getline(caret.y).size();
caret.x = static_cast<decltype(caret.x)>(textbase_.getline(caret.y).size());
changed = true;
}
}
@@ -2309,7 +2309,7 @@ namespace nana{ namespace widgets
break;
case keyboard::os_end:
if (caret.x < lnsz) {
caret.x = lnsz;
caret.x = static_cast<decltype(caret.x)>(lnsz);
changed = true;
}
break;

View File

@@ -97,7 +97,7 @@ namespace nana
{
int x = r.x + (static_cast<int>(r.width) - 14) / 2;
int y = r.y + (static_cast<int>(r.height) - 14) / 2;
::nana::color clr;
switch(sta)
@@ -114,12 +114,10 @@ namespace nana
graph.rectangle(r, true, bgcolor_);
facade<element::cross> cross;
cross.draw(graph, {}, clr, { x, y, 14, 6 }, element_state::normal);
//nana::paint::gadget::cross(graph, x, y, 14, 6, clr); //deprecated
}
virtual void close(graph_reference graph, const nana::rectangle& r, state_t sta)
{
//nana::paint::gadget::close_16_pixels(graph, r.x + (r.width - 16) / 2, r.y + (r.height - 16) / 2, 1, colors::black); //deprecated
facade<element::x_icon> x_icon;
x_icon.draw(graph, {}, colors::black, { r.x + static_cast<int>(r.width - 16) / 2, r.y + static_cast<int>(r.height - 16) / 2, 16, 16 }, element_state::normal);
if(item_renderer::highlight == sta)
@@ -144,8 +142,6 @@ namespace nana
else if (!active)
clr = ::nana::color{ 0x92, 0x99, 0xA4 };
//gadget::close_16_pixels(graph, r.x - (16 - r.width) / 2, r.y - (16 - r.height) / 2, 1, clr); //deprecated
facade<element::x_icon> x_icon;
x_icon.draw(graph, {}, colors::black, { r.x + static_cast<int>(r.width - 16) / 2, r.y + static_cast<int>(r.height - 16) / 2, 16, 16 }, element_state::normal);
@@ -153,19 +149,16 @@ namespace nana
virtual void back(graph_reference graph, const nana::rectangle& r, state_t sta)
{
//using namespace nana::paint::gadget; //deprecated
_m_draw_arrow(graph, r, sta, direction::west);
}
virtual void next(graph_reference graph, const nana::rectangle& r, state_t sta)
{
//using namespace nana::paint::gadget; //deprecated
_m_draw_arrow(graph, r, sta, direction::east);
}
virtual void list(graph_reference graph, const nana::rectangle& r, state_t sta)
{
//using namespace nana::paint::gadget; //deprecated
_m_draw_arrow(graph, r, sta, direction::south);
}
private:
@@ -1448,7 +1441,6 @@ namespace nana
private:
void _m_calc_metrics(graph_reference graph, std::forward_list<item>& items)
{
const auto height_px = graph.height();
std::vector<unsigned> pxs;
unsigned pixels = 0;

View File

@@ -1,108 +0,0 @@
/*
* Graphics Gadget Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/paint/gadget.cpp
*/
#include <nana/paint/graphics.hpp>
#include <nana/paint/gadget.hpp>
namespace nana
{
namespace paint
{
namespace gadget
{
void close_16_pixels(::nana::paint::graphics& graph, int x, int y, unsigned style, const ::nana::color& clr)
{
graph.set_color(clr);
if(0 == style)
{
x += 3;
y += 3;
graph.line({ x, y }, { x + 9, y + 9 });
graph.line({ x + 1, y }, { x + 9, y + 8 });
graph.line({ x, y + 1 }, { x + 8, y + 9 });
graph.line({ x + 9, y }, { x, y + 9 });
graph.line({ x + 8, y }, { x, y + 8 });
graph.line({ x + 9, y + 1 }, { x + 1, y + 9 });
}
else
{
x += 4;
y += 4;
graph.line({ x, y }, { x + 7, y + 7 });
graph.line({ x + 1, y }, { x + 7, y + 6 });
graph.line({ x, y + 1 }, { x + 6, y + 7 });
graph.line({ x + 7, y }, { x, y + 7 });
graph.line({ x + 6, y }, { x, y + 6 });
graph.line({ x + 7, y + 1 }, { x + 1, y + 7 });
}
}
void cross(graphics& graph, int x, int y, unsigned size, unsigned thickness, const ::nana::color& clr)
{
if (thickness + 2 <= size)
{
int gap = (size - thickness) / 2;
nana::point ps[12];
ps[0].x = x + gap;
ps[1].x = ps[0].x + thickness - 1;
ps[1].y = ps[0].y = y;
ps[2].x = ps[1].x;
ps[2].y = y + gap;
ps[3].x = ps[2].x + gap;
ps[3].y = ps[2].y;
ps[4].x = ps[3].x;
ps[4].y = ps[3].y + thickness - 1;
ps[5].x = ps[1].x;
ps[5].y = ps[4].y;
ps[6].x = ps[5].x;
ps[6].y = ps[5].y + gap;
ps[7].x = x + gap;
ps[7].y = ps[6].y;
ps[8].x = ps[7].x;
ps[8].y = ps[4].y;
ps[9].x = x;
ps[9].y = ps[4].y;
ps[10].x = x;
ps[10].y = y + gap;
ps[11].x = x + gap;
ps[11].y = y + gap;
graph.set_color(clr.blend(colors::black, true));
for (int i = 0; i < 11; ++i)
graph.line(ps[i], ps[i + 1]);
graph.line(ps[11], ps[0]);
graph.set_color(clr);
graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thickness - 2, thickness - 2 }, true);
graph.rectangle(rectangle{ ps[0].x + 1, ps[0].y + 1, thickness - 2, (gap << 1) + thickness - 2 }, true);
}
}
}//end namespace gadget
}//end namespace paint
}//end namespace nana

View File

@@ -845,13 +845,13 @@ namespace paint
BITMAPFILEHEADER bmFileHeader = { 0 };
bmFileHeader.bfType = 0x4d42; //bmp
bmFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmFileHeader.bfSize = bmFileHeader.bfOffBits + imageBytes;
bmFileHeader.bfSize = bmFileHeader.bfOffBits + static_cast<DWORD>(imageBytes);
HANDLE hFile = ::CreateFileW(static_cast<std::wstring>(::nana::charset(file_utf8, ::nana::unicode::utf8)).data(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD dwWrite = 0;
::WriteFile(hFile, &bmFileHeader, sizeof(BITMAPFILEHEADER), &dwWrite, nullptr);
::WriteFile(hFile, &bmpInfo.bmiHeader, sizeof(BITMAPINFOHEADER), &dwWrite, nullptr);
::WriteFile(hFile, pData, imageBytes, &dwWrite, nullptr);
::WriteFile(hFile, pData, static_cast<DWORD>(imageBytes), &dwWrite, nullptr);
::CloseHandle(hFile);
::DeleteObject(hBmp);