From ad0dcc0bcf16a65e0e0f2cb8a7647663639a0c97 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 3 May 2015 17:38:58 +0800 Subject: [PATCH] fix some MinGW compiling errors --- source/gui/detail/win32/bedrock.cpp | 8 ++-- source/gui/msgbox.cpp | 17 +++++---- source/system/dataexch.cpp | 58 +++++++++++------------------ 3 files changed, 34 insertions(+), 49 deletions(-) diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index 71ae2f02..16437732 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -449,7 +449,7 @@ namespace detail { (msgbox(modal_window, STR("An uncaptured std::exception during message pumping: ")).icon(msgbox::icon_information) <(wd->root), &point); arg.upwards = (pmdec.mouse.button.wheel_delta >= 0); - arg.distance = std::abs(pmdec.mouse.button.wheel_delta); + arg.distance = static_cast(arg.upwards ? pmdec.mouse.button.wheel_delta : -pmdec.mouse.button.wheel_delta); arg.pos.x = static_cast(point.x) - wd->pos_root.x; arg.pos.y = static_cast(point.y) - wd->pos_root.y; @@ -1641,7 +1641,7 @@ namespace detail { if (try_destroy) native_interface::close_window(impl_->menu.window); - + impl_->menu.window = impl_->menu.owner = nullptr; impl_->menu.has_keyboard = false; } @@ -1687,7 +1687,7 @@ namespace detail else if (::nana::category::flags::lite_widget == child->other.category) map_through_widgets(child, drawable); } -#endif +#endif } bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd) diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index b32bcfea..de471567 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -3,8 +3,8 @@ * 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 + * 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/gui/msgbox.hpp @@ -23,6 +23,7 @@ #include #include #include +#include //include std::abs #if defined(NANA_WINDOWS) #include #elif defined(NANA_X11) @@ -489,7 +490,7 @@ namespace nana close(); valid_input_ = true; }); - + btn_cancel_.create(*this); btn_cancel_.i18n(i18n_eval("Cancel")); btn_cancel_.events().click.connect_unignorable([this]{ @@ -501,7 +502,7 @@ namespace nana place_.bind(*this); std::stringstream ss_content; ss_content << "dock.create(parent); @@ -1043,7 +1044,7 @@ namespace nana auto day = impl->wdg_day.to_int(); impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day - + if (day > days) day = days; @@ -1078,7 +1079,7 @@ namespace nana : fbox(fb), label_text(std::move(labelstr)) {} }; - + inputbox::path::path(::nana::string label, const filebox& fb) : impl_(new implement(fb, std::move(label))) { @@ -1094,7 +1095,7 @@ namespace nana return impl_->value; } - + //Implementation of abstract_content const ::nana::string& inputbox::path::label() const { diff --git a/source/system/dataexch.cpp b/source/system/dataexch.cpp index a7109a48..8929b240 100644 --- a/source/system/dataexch.cpp +++ b/source/system/dataexch.cpp @@ -59,7 +59,6 @@ namespace nana{ namespace system{ HDC hDC = ::GetDC(NULL); if (::GetDIBits(hDC, (HBITMAP)g.pixmap(), 0, 1, NULL, (BITMAPINFO *)&bmi, DIB_RGB_COLORS) == 0) { assert(false); - int err = ::GetLastError(); ::ReleaseDC(NULL, hDC); return false; } @@ -72,41 +71,26 @@ namespace nana{ namespace system{ // Bitmaps are huge, so to avoid unnegligible extra copy, this routine does not use private _m_set method. HGLOBAL h_gmem = ::GlobalAlloc(GHND | GMEM_SHARE, header_size + bitmap_bytes); void * gmem = ::GlobalLock(h_gmem); - if (!gmem) { - assert(false); - goto Label_GlobalFree; + if (gmem) { + char* p = (char*)gmem; + // Fix BITMAPINFOHEADER obtained from GetDIBits WinAPI + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biHeight = ::abs(bmi.bmiHeader.biHeight); + memcpy(p, &bmi, header_size); + p += header_size; + // many programs do not support bottom-up DIB, so reversing row order is needed. + for (int y=0; y(res), size); const nana::char_t * utf32ptr = reinterpret_cast(utf32str.c_str()); str.append(utf32ptr + 1, utf32ptr + utf32str.size() / sizeof(nana::char_t)); -#else +#else str.reserve(size / sizeof(nana::char_t)); str.append(reinterpret_cast(res), reinterpret_cast(res) + size / sizeof(nana::char_t)); nana::string::size_type pos = str.find_last_not_of(nana::char_t(0)); @@ -226,7 +210,7 @@ namespace nana{ namespace system{ nana::detail::platform_spec & spec = nana::detail::platform_spec::instance(); native_window_type requester = nullptr; spec.lock_xlib(); - + { internal_scope_guard isg; detail::bedrock::core_window_t * wd = detail::bedrock::instance().focus();