get ready for Linux

This commit is contained in:
cnjinhao
2015-02-04 10:26:08 +08:00
parent ec78324743
commit fd5ff571a7
27 changed files with 180 additions and 176 deletions

View File

@@ -1,7 +1,7 @@
/*
* A Bedrock Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* 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
@@ -377,6 +377,12 @@ namespace detail
return impl_->estore;
}
void bedrock::map_through_widgets(core_window_t* wd, native_drawable_type drawable)
{
//No implementation for Linux
}
bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd)
{
if(evt_code != arg.evt_code)

View File

@@ -1008,7 +1008,7 @@ namespace detail
arg.evt_code = event_code::mouse_up;
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
auto evt_ptr = msgwnd->together.events_ptr;
//auto evt_ptr = msgwnd->together.events_ptr; //deprecated
if (fire_click)
{

View File

@@ -679,7 +679,7 @@ namespace detail
{
//Copy the root buffer that wd specified into DeviceContext
#if defined(NANA_LINUX)
wd->drawer.map(reinterpret_cast<window>(wd));
wd->drawer.map(reinterpret_cast<window>(wd), forced);
#elif defined(NANA_WINDOWS)
if(nana::system::this_thread_id() == wd->thread_id)
wd->drawer.map(reinterpret_cast<window>(wd), forced);

View File

@@ -1,7 +1,7 @@
/*
* Elements of GUI Gadgets
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* 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
@@ -411,7 +411,7 @@ namespace nana
pixels -= 2;
}
}
break;
default:break;
}
return true;
}

View File

@@ -34,17 +34,17 @@ namespace nana
: public form
{
public:
msgbox_window(window wd, const nana::string& title, msgbox::button_t btn, msgbox::icon_t ico)
: form(wd, nana::rectangle(1, 1, 1, 1), appear::decorate<>()),
msgbox_window(window wd, const ::nana::string& title, msgbox::button_t btn, msgbox::icon_t ico)
: form(wd, rectangle(1, 1, 1, 1), appear::decorate<>()),
owner_(wd), pick_(msgbox::pick_yes)
{
this->caption(title);
drawing dw(*this);
dw.draw([this](::nana::paint::graphics& graph)
dw.draw([this](paint::graphics& graph)
{
graph.rectangle(nana::rectangle{0, 0, graph.width(), graph.height() - 50}, 0xFFFFFF, true);
graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white);
if(ico_.empty() == false)
ico_.stretch(ico_.size(), graph, ::nana::rectangle{12, 25, 32, 32});
ico_.stretch(ico_.size(), graph, rectangle{12, 25, 32, 32});
});
unsigned width_pixel = 45;
@@ -298,7 +298,7 @@ namespace nana
{
nana::paint::pixel_buffer pxbuf(32, 32);
pxbuf.put(reinterpret_cast<const unsigned char*>(rawpx), 32, 32, 32, 4*32, true);
ico_.make(32, 32);
ico_.make({32, 32});
pxbuf.paste(ico_.handle(), 0, 0);
}
}
@@ -869,6 +869,8 @@ namespace nana
window inputbox::date::create(window parent, unsigned label_px)
{
auto today = ::nana::date().read();
auto impl = impl_.get();
impl->dock.create(parent);
@@ -887,7 +889,7 @@ namespace nana
left += 104;
impl->wdg_day.create(impl->dock, rectangle{ left, 0, 38, 0 });
impl->wdg_day.range(1, 31, 1);
impl->wdg_day.range(1, ::nana::date::month_days(today.year, today.month), 1);
impl->wdg_day.set_accept_integer();
left += 48;
@@ -895,15 +897,14 @@ namespace nana
impl->wdg_year.range(1601, 9999, 1);
impl->wdg_year.set_accept_integer();
auto date = ::nana::date().read();
impl->wdg_month.option(date.month - 1);
impl->wdg_month.option(today.month - 1);
std::wstringstream ss;
ss << date.day;
ss << today.day;
impl->wdg_day.value(ss.str());
ss.str(L"");
ss.clear();
ss << date.year;
ss << today.year;
impl->wdg_year.value(ss.str());
impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg)
@@ -935,21 +936,15 @@ namespace nana
auto make_days = [impl]
{
int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
auto month = impl->wdg_month.option() + 1;
if (2 == month)
{
auto year = impl->wdg_year.to_int();
if (((0 == year % 4) && (year % 100)) || (0 == (year % 400)))
days[1] = 29;
}
auto year = impl->wdg_year.to_int();
int days = ::nana::date::month_days(year, month);
auto day = impl->wdg_day.to_int();
impl->wdg_day.range(1, days[month - 1], 1); //It resets the current value of wdg_day
impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day
if (day > days[month - 1])
day = days[month - 1];
if (day > days)
day = days;
std::wstringstream ss;
ss << day;

View File

@@ -47,8 +47,7 @@ namespace nana
#else
if (0 == index_)
{
position_.x = position_.y = 0;
size_ = detail::native_interface::primary_monitor_size();
area_ = detail::native_interface::primary_monitor_size();
return;
}
#endif
@@ -61,7 +60,7 @@ namespace nana
}
public:
//Implementation of display
std::size_t index() const override
std::size_t get_index() const override
{
return index_;
}
@@ -72,7 +71,7 @@ namespace nana
}
private:
const std::size_t index_;
::nana::rectangle area_;
::nana::rectangle area_;
};
//class screen

View File

@@ -20,6 +20,9 @@
namespace nana
{
arg_combox::arg_combox(combox& wdg): widget(wdg)
{}
namespace drawerbase
{
namespace combox
@@ -29,7 +32,7 @@ namespace nana
{
public:
event_agent(::nana::combox& wdg)
: widget_{wdg}
: widget_(wdg)
{}
void first_change() override{} //empty, because combox does not have this event.

View File

@@ -3663,7 +3663,7 @@ namespace nana
}
}//end namespace drawerbase
arg_listbox::arg_listbox(drawerbase::listbox::item_proxy& m, bool selected)
arg_listbox::arg_listbox(const drawerbase::listbox::item_proxy& m, bool selected)
: item(m), selected(selected)
{

View File

@@ -4,7 +4,7 @@
namespace nana
{
arg_slider::arg_slider(slider& wdg)
: widget{ wdg }
: widget(wdg)
{}
namespace drawerbase

View File

@@ -7,7 +7,7 @@
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/widgets/spanbox.cpp
* @file: nana/gui/widgets/spinbox.cpp
*/
#include <nana/gui/widgets/spinbox.hpp>
@@ -17,6 +17,9 @@
namespace nana
{
arg_spinbox::arg_spinbox(spinbox& wdg): widget(wdg)
{}
namespace drawerbase
{
namespace spinbox
@@ -26,7 +29,7 @@ namespace nana
{
public:
event_agent(::nana::spinbox& wdg)
: widget_{ wdg }
: widget_(wdg)
{}
void first_change() override{} //empty, because spinbox does not have this event.
@@ -685,4 +688,4 @@ namespace nana
API::refresh_window(*this);
}
}
}//end namespace nana
}//end namespace nana

View File

@@ -18,7 +18,7 @@
namespace nana
{
arg_textbox::arg_textbox(textbox& wdg)
: widget{wdg}
: widget(wdg)
{}
namespace drawerbase {

View File

@@ -18,7 +18,7 @@
namespace nana
{
arg_toolbar::arg_toolbar(toolbar& tbar, std::size_t btn)
: widget{ tbar }, button{btn}
: widget(tbar), button{btn}
{}
namespace drawerbase

View File

@@ -19,7 +19,7 @@
namespace nana
{
arg_treebox::arg_treebox(treebox& wdg, drawerbase::treebox::item_proxy& m, bool op)
: widget{ wdg }, item{ m }, operated{op}
: widget(wdg), item(m), operated{op}
{}
namespace drawerbase
@@ -74,7 +74,92 @@ namespace nana
return nullptr;
}
class tooltip_window;
class tlwnd_drawer
: public drawer_trigger, public compset_interface
{
public:
typedef drawer_trigger::graph_reference graph_reference;
void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
{
if(renderer && compset_placer)
{
renderer_ = *renderer;
placer_ = *compset_placer;
item_attr_ = item_attr;
_m_draw();
}
}
private:
void _m_draw()
{
item_r_.x = item_r_.y = 0;
item_r_.width = placer_->item_width(*this->graph_, item_attr_);
item_r_.height = placer_->item_height(*this->graph_);
comp_attribute_t attr;
if(comp_attribute(component::text, attr))
{
nana::paint::graphics item_graph({ item_r_.width, item_r_.height });
item_graph.typeface(graph_->typeface());
renderer_->set_color(widget_->bgcolor(), widget_->fgcolor());
renderer_->bground(item_graph, this);
renderer_->expander(item_graph, this);
renderer_->crook(item_graph, this);
renderer_->icon(item_graph, this);
renderer_->text(item_graph, this);
item_graph.paste(attr.area, *graph_, 1, 1);
graph_->rectangle(false, colors::black);
}
}
private:
// Implementation of drawer_trigger
void attached(widget_reference wd, graph_reference graph) override
{
widget_ = &wd;
graph_ = &graph;
graph.typeface(widget_->typeface());
}
private:
// Implementation of compset_interface
virtual const item_attribute_t& item_attribute() const override
{
return item_attr_;
}
virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override
{
comp_attr.area = item_r_;
return placer_->locate(comp, item_attr_, &comp_attr.area);
}
private:
::nana::paint::graphics * graph_;
::nana::pat::cloneable<renderer_interface> renderer_;
::nana::pat::cloneable<compset_placer_interface> placer_;
widget *widget_;
item_attribute_t item_attr_;
nana::rectangle item_r_;
};//end class tlwnd_drawer
class tooltip_window
: public widget_object<category::root_tag, tlwnd_drawer>
{
public:
tooltip_window(window wd, const rectangle& r)
: widget_object<category::root_tag, tlwnd_drawer>(wd, false, rectangle(r).pare_off(-1), appear::bald<appear::floating>())
{
API::take_active(handle(), false, nullptr);
}
drawer_trigger_t & impl()
{
return get_drawer_trigger();
}
};//end class tooltip_window
//item_locator should be defined before the definition of basic_implement
class trigger::item_locator
@@ -1368,94 +1453,6 @@ namespace nana
//Treebox Implementation
namespace treebox
{
class tlwnd_drawer
: public drawer_trigger, public compset_interface
{
public:
typedef drawer_trigger::graph_reference graph_reference;
void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
{
if(renderer && compset_placer)
{
renderer_ = *renderer;
placer_ = *compset_placer;
item_attr_ = item_attr;
_m_draw();
}
}
private:
void _m_draw()
{
item_r_.x = item_r_.y = 0;
item_r_.width = placer_->item_width(*this->graph_, item_attr_);
item_r_.height = placer_->item_height(*this->graph_);
comp_attribute_t attr;
if(comp_attribute(component::text, attr))
{
nana::paint::graphics item_graph({ item_r_.width, item_r_.height });
item_graph.typeface(graph_->typeface());
renderer_->set_color(widget_->bgcolor(), widget_->fgcolor());
renderer_->bground(item_graph, this);
renderer_->expander(item_graph, this);
renderer_->crook(item_graph, this);
renderer_->icon(item_graph, this);
renderer_->text(item_graph, this);
item_graph.paste(attr.area, *graph_, 1, 1);
graph_->rectangle(false, colors::black);
}
}
private:
// Implementation of drawer_trigger
void attached(widget_reference wd, graph_reference graph) override
{
widget_ = &wd;
graph_ = &graph;
graph.typeface(widget_->typeface());
}
private:
// Implementation of compset_interface
virtual const item_attribute_t& item_attribute() const override
{
return item_attr_;
}
virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override
{
comp_attr.area = item_r_;
return placer_->locate(comp, item_attr_, &comp_attr.area);
}
private:
::nana::paint::graphics * graph_;
::nana::pat::cloneable<renderer_interface> renderer_;
::nana::pat::cloneable<compset_placer_interface> placer_;
widget *widget_;
item_attribute_t item_attr_;
nana::rectangle item_r_;
};//end class tlwnd_drawer
class tooltip_window
: public widget_object<category::root_tag, tlwnd_drawer>
{
public:
tooltip_window(window wd, const rectangle& r)
: widget_object<category::root_tag, tlwnd_drawer>(wd, false, rectangle(r).pare_off(-1), appear::bald<appear::floating>())
{
API::take_active(handle(), false, nullptr);
}
drawer_trigger_t & impl()
{
return get_drawer_trigger();
}
};//end class tooltip_window
//class trigger
//struct treebox_node_type
trigger::treebox_node_type::treebox_node_type()