fix some compiler errors and warnings
This commit is contained in:
parent
b1ce0eaff2
commit
043ebad317
@ -1117,9 +1117,9 @@ namespace nana
|
|||||||
delete impl_;
|
delete impl_;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto menu::append(std::string text_utf8, const menu::event_fn_t& f) -> item_proxy
|
auto menu::append(std::string text_utf8, const menu::event_fn_t& callback) -> item_proxy
|
||||||
{
|
{
|
||||||
impl_->mbuilder.data().items.emplace_back(new item_type(std::move(text_utf8, callback));
|
impl_->mbuilder.data().items.emplace_back(new item_type(std::move(text_utf8), callback));
|
||||||
return item_proxy(size() - 1, *impl_->mbuilder.data().items.back());
|
return item_proxy(size() - 1, *impl_->mbuilder.data().items.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,7 +1159,7 @@ namespace nana
|
|||||||
|
|
||||||
void menu::text(std::size_t index, std::string text_utf8)
|
void menu::text(std::size_t index, std::string text_utf8)
|
||||||
{
|
{
|
||||||
impl_->mbuilder.data().items.at(index).text.swap(text_utf8);
|
impl_->mbuilder.data().items.at(index)->text.swap(text_utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menu::link(std::size_t index, menu& menu_obj)
|
bool menu::link(std::size_t index, menu& menu_obj)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef NANA_PAINT_DETAIL_IMAGE_ICO_EX_HPP
|
#ifndef NANA_PAINT_DETAIL_IMAGE_ICO_EX_HPP
|
||||||
#define NANA_PAINT_DETAIL_IMAGE_ICO_EX_HPP
|
#define NANA_PAINT_DETAIL_IMAGE_ICO_EX_HPP
|
||||||
|
|
||||||
#include "image_pixbuf.hpp"
|
#include "image_pixbuf.hpp"
|
||||||
|
|
||||||
namespace nana {
|
namespace nana {
|
||||||
namespace paint {
|
namespace paint {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
// These next two structs represent how the icon information is stored
|
// These next two structs represent how the icon information is stored
|
||||||
// in an ICO file.
|
// in an ICO file.
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -52,21 +52,21 @@ typedef struct
|
|||||||
uint8_t icXOR[1]; // DIB bits for XOR mask
|
uint8_t icXOR[1]; // DIB bits for XOR mask
|
||||||
uint8_t icAND[1]; // DIB bits for AND mask
|
uint8_t icAND[1]; // DIB bits for AND mask
|
||||||
} ICONIMAGE, *LPICONIMAGE;
|
} ICONIMAGE, *LPICONIMAGE;
|
||||||
|
|
||||||
|
|
||||||
class image_ico_ex
|
class image_ico_ex
|
||||||
: public basic_image_pixbuf
|
: public basic_image_pixbuf
|
||||||
{
|
{
|
||||||
bool _m_read_ico(const void* data, std::size_t size)
|
bool _m_read_ico(const void* data, std::size_t size)
|
||||||
{
|
{
|
||||||
auto width = 0;
|
auto width = 0;
|
||||||
auto height = 0;
|
auto height = 0;
|
||||||
auto buffer = (unsigned char *)data;
|
auto buffer = (unsigned char *)data;
|
||||||
auto icoDir = reinterpret_cast<LPICONDIR>(buffer);
|
auto icoDir = reinterpret_cast<LPICONDIR>(buffer);
|
||||||
int iconsCount = icoDir->idCount;
|
int iconsCount = icoDir->idCount;
|
||||||
if (icoDir->idReserved != 0 || icoDir->idType != 1 || iconsCount == 0 || iconsCount > 20)
|
if (icoDir->idReserved != 0 || icoDir->idType != 1 || iconsCount == 0 || iconsCount > 20)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto cursor = buffer;
|
auto cursor = buffer;
|
||||||
cursor += 6;
|
cursor += 6;
|
||||||
auto dirEntry = reinterpret_cast<ICONDIRENTRY*>(cursor);
|
auto dirEntry = reinterpret_cast<ICONDIRENTRY*>(cursor);
|
||||||
@ -83,11 +83,11 @@ class image_ico_ex
|
|||||||
width = w;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
offset = dirEntry->dwImageOffset;
|
offset = dirEntry->dwImageOffset;
|
||||||
maxSize = w * h;
|
maxSize = w * h;
|
||||||
maxBitCount = bitCount;
|
maxBitCount = bitCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset == 0) return false;
|
if (offset == 0) return false;
|
||||||
|
|
||||||
cursor = buffer;
|
cursor = buffer;
|
||||||
@ -119,8 +119,8 @@ class image_ico_ex
|
|||||||
{
|
{
|
||||||
for (auto x = 0; x < width; x++)
|
for (auto x = 0; x < width; x++)
|
||||||
for (auto y = 0; y < height; y++)
|
for (auto y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
pixbuf_.alpha_channel(true);
|
pixbuf_.alpha_channel(true);
|
||||||
auto shift2 = 3 * (x + (height - y - 1) * width);
|
auto shift2 = 3 * (x + (height - y - 1) * width);
|
||||||
pixel_color_t image;
|
pixel_color_t image;
|
||||||
image.element.red = cursor[shift2 + 2];
|
image.element.red = cursor[shift2 + 2];
|
||||||
@ -138,10 +138,10 @@ class image_ico_ex
|
|||||||
cursor += 256 * 4;
|
cursor += 256 * 4;
|
||||||
for (auto x = 0; x < width; x++)
|
for (auto x = 0; x < width; x++)
|
||||||
for (auto y = 0; y < height; y++)
|
for (auto y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
pixbuf_.alpha_channel(true);
|
pixbuf_.alpha_channel(true);
|
||||||
|
|
||||||
auto shift2 = (x + (height - y - 1) * width);
|
auto shift2 = (x + (height - y - 1) * width);
|
||||||
auto index = 4 * cursor[shift2];
|
auto index = 4 * cursor[shift2];
|
||||||
pixel_color_t image;
|
pixel_color_t image;
|
||||||
image.element.red = colors[index + 2];
|
image.element.red = colors[index + 2];
|
||||||
@ -159,8 +159,8 @@ class image_ico_ex
|
|||||||
cursor += 16 * 4;
|
cursor += 16 * 4;
|
||||||
for (auto x = 0; x < width; x++)
|
for (auto x = 0; x < width; x++)
|
||||||
for (auto y = 0; y < height; y++)
|
for (auto y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
auto shift2 = (x + (height - y - 1) * width);
|
auto shift2 = (x + (height - y - 1) * width);
|
||||||
auto index = cursor[shift2 / 2];
|
auto index = cursor[shift2 / 2];
|
||||||
if (shift2 % 2 == 0)
|
if (shift2 % 2 == 0)
|
||||||
index = (index >> 4) & 0xF;
|
index = (index >> 4) & 0xF;
|
||||||
@ -186,8 +186,8 @@ class image_ico_ex
|
|||||||
while (boundary % 32 != 0) boundary++;
|
while (boundary % 32 != 0) boundary++;
|
||||||
for (auto x = 0; x < width; x++)
|
for (auto x = 0; x < width; x++)
|
||||||
for (auto y = 0; y < height; y++)
|
for (auto y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
auto shift2 = (x + (height - y - 1) * boundary);
|
auto shift2 = (x + (height - y - 1) * boundary);
|
||||||
auto index = cursor[shift2 / 8];
|
auto index = cursor[shift2 / 8];
|
||||||
|
|
||||||
// select 1 bit only
|
// select 1 bit only
|
||||||
@ -214,9 +214,9 @@ class image_ico_ex
|
|||||||
while (boundary % 32 != 0) boundary++;
|
while (boundary % 32 != 0) boundary++;
|
||||||
for (auto y = 0; y < height; y++)
|
for (auto y = 0; y < height; y++)
|
||||||
for (auto x = 0; x < width; x++)
|
for (auto x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
unsigned char bit = 7 - (x % 8);
|
unsigned char bit = 7 - (x % 8);
|
||||||
auto shift2 = (x + (height - y - 1) * boundary) / 8;
|
auto shift2 = (x + (height - y - 1) * boundary) / 8;
|
||||||
auto mask = (0x01 & (static_cast<unsigned char>(cursor[shift2]) >> bit));
|
auto mask = (0x01 & (static_cast<unsigned char>(cursor[shift2]) >> bit));
|
||||||
auto pc = pixbuf_.pixel(x, y);
|
auto pc = pixbuf_.pixel(x, y);
|
||||||
auto alpha = pc.element.alpha_channel;
|
auto alpha = pc.element.alpha_channel;
|
||||||
@ -225,39 +225,38 @@ class image_ico_ex
|
|||||||
pixbuf_.pixel(x, y, pc);
|
pixbuf_.pixel(x, y, pc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool open(const std::experimental::filesystem::path& ico_file) override
|
bool open(const std::experimental::filesystem::path& ico_file) override
|
||||||
{
|
{
|
||||||
std::ifstream file(ico_file.string(), std::ios::binary);
|
std::ifstream file(ico_file.string(), std::ios::binary);
|
||||||
if (!file.is_open()) return false;
|
if (!file.is_open()) return false;
|
||||||
|
|
||||||
// allocates a buffer for the image
|
// allocates a buffer for the image
|
||||||
std::streampos size = 0;
|
file.seekg(0, std::ios::end);
|
||||||
file.seekg(0, std::ios::end);
|
const auto bytes = static_cast<std::size_t>(file.tellg());
|
||||||
size = file.tellg() - size;
|
file.seekg(0, std::ios::beg);
|
||||||
file.seekg(0, std::ios::beg);
|
auto buffer = new char[bytes];
|
||||||
auto buffer = new char[size];
|
|
||||||
|
// read data from the file and set them in the buffer
|
||||||
// read data from the file and set them in the buffer
|
file.read(buffer, bytes);
|
||||||
file.read(buffer, size);
|
auto okret = _m_read_ico(buffer, bytes);
|
||||||
auto okret = _m_read_ico(buffer, size);
|
|
||||||
|
// delete buffer and return
|
||||||
// delete buffer and return
|
delete[] buffer;
|
||||||
delete[] buffer;
|
return okret;
|
||||||
return okret;
|
}
|
||||||
}
|
|
||||||
|
bool open(const void* data, std::size_t bytes) override
|
||||||
bool open(const void* data, std::size_t bytes) override
|
{
|
||||||
{
|
return _m_read_ico(data, bytes);
|
||||||
return _m_read_ico(data, bytes);
|
}
|
||||||
}
|
|
||||||
|
};
|
||||||
};
|
}//end namespace detail
|
||||||
}//end namespace detail
|
}//end namespace paint
|
||||||
}//end namespace paint
|
}//end namespace nana
|
||||||
}//end namespace nana
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user