Merge branch 'develop' of https://github.com/beru/nana into beru-develop

Conflicts:
	source/gui/widgets/skeletons/text_editor.cpp
	source/gui/widgets/textbox.cpp
	source/paint/detail/image_bmp.hpp
	source/paint/detail/image_ico.hpp
This commit is contained in:
Jinhao
2015-08-01 22:08:06 +08:00
22 changed files with 322 additions and 46 deletions

View File

@@ -25,24 +25,24 @@ namespace nana{ namespace paint
struct bitmap_file_header
{
unsigned short bfType;
unsigned long bfSize;
unsigned bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned long bfOffBits;
unsigned bfOffBits;
} __attribute__((packed));
struct bitmap_info_header {
unsigned long biSize;
long biWidth;
long biHeight;
unsigned biSize;
int biWidth;
int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
unsigned long biCompression;
unsigned long biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
unsigned long biClrUsed;
unsigned long biClrImportant;
unsigned biCompression;
unsigned biSizeImage;
int biXPelsPerMeter;
int biYPelsPerMeter;
unsigned biClrUsed;
unsigned biClrImportant;
}__attribute__((packed));
struct rgb_quad
@@ -75,6 +75,12 @@ namespace nana{ namespace paint
this->close();
}
bool open(const void* data, std::size_t bytes)
{
// TODO: read a BMP file from memory
return false;
}
bool open(const nana::char_t* filename) override
{
if(nullptr == filename) return false;

View File

@@ -22,14 +22,15 @@ namespace nana{ namespace paint
public:
image_ico(bool is_ico);
bool open(const nana::char_t* filename) override;
bool open(const void* data, std::size_t bytes);
bool alpha_channel() const override;
bool empty() const override;
void close() override;
nana::size size() const override;
virtual void paste(const nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override;
virtual void stretch(const nana::rectangle&, graph_reference graph, const nana::rectangle& r) const override;
const ptr_t & ptr() const;
private:
const bool is_ico_;

View File

@@ -812,7 +812,7 @@ namespace paint
size_.width = size_.height = 0;
}
void graphics::save_as_file(const char* file)
void graphics::save_as_file(const char* file) const
{
if(handle_)
{

View File

@@ -70,6 +70,31 @@ namespace paint
return false;
}
bool image_ico::open(void* buff, size_t sz)
{
close();
#if defined(NANA_WINDOWS)
HICON handle = CreateIconFromResource((PBYTE)buff, sz, TRUE, 0x00030000);
if(handle)
{
ICONINFO info;
if (::GetIconInfo(handle, &info) != 0)
{
HICON * p = new HICON(handle);
ptr_ = std::shared_ptr<HICON>(p, handle_deleter());
size_.width = (info.xHotspot << 1);
size_.height = (info.yHotspot << 1);
::DeleteObject(info.hbmColor);
::DeleteObject(info.hbmMask);
return true;
}
}
#else
if(is_ico_){} //kill the unused compiler warning in Linux.
#endif
return false;
}
bool image_ico::alpha_channel() const
{
return false;
@@ -236,6 +261,13 @@ namespace paint
return false;
}
bool image::open_icon(void* buff, size_t sz)
{
image::image_impl_interface * helper = new detail::image_ico(true);
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
return helper->open(buff, sz);
}
bool image::empty() const
{
return ((nullptr == image_ptr_) || image_ptr_->empty());