diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 9ee2e7c07..3ce6e4d7a 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -1,7 +1,7 @@ /* * Nana GUI Programming Interface Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2023 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2024 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -133,7 +133,10 @@ namespace api std::optional caret_position(window); - upoint im_input(window, const upoint& insert_pos, const std::wstring&, bool candidate); + upoint im_input(window, const upoint& insert_pos, const std::wstring&, bool candidate); + + /// Cancel the candidate mode + void im_cancel(window); }//end namespace dev @@ -515,6 +518,8 @@ namespace api std::size_t window_dpi(window); dragdrop_status window_dragdrop_status(::nana::window); + void keyboard_default_language(const std::string& lang); + /// Configures the qwerty keyboard for a text editor /** * @param wd The handle to a text editor window. Such as textbox and combox. @@ -527,7 +532,7 @@ namespace api /// Configures the numeric keyboard. It returns true if virtual keyboard is enabled and /// the specified window is a text editor window, false otherwise. - bool keyboard_numeric(window); + bool keyboard_numeric(window, bool padding); }//end namespace api namespace API = api; diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 1a7d0d4c0..b918a6142 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -1,7 +1,7 @@ /* * Nana GUI Programming Interface Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2023 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2024 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -460,11 +460,21 @@ namespace api { internal_scope_guard lock; if (is_window(wd) && wd->annex.text_editor) - return wd->annex.text_editor->im_input(insert_pos, str, candidate); return {}; } + /// Cancels the candiate mode + /** + * Cancels the candidate mode when the virtual keyboard window is closed. + */ + void im_cancel(window wd) + { + internal_scope_guard lock; + if (is_window(wd) && wd->annex.text_editor) + wd->annex.text_editor->im_cancel(); + } + }//end namespace dev @@ -1707,6 +1717,12 @@ namespace api return dragdrop_status::not_ready; } + void keyboard_default_language(const std::string& lang) + { + internal_scope_guard lock; + restrict::bedrock.vkeyboard().default_im_value() = lang; + } + /// Configures the qwerty keyboard for a text editor bool keyboard_qwerty(window wd, std::vector langs, keyboard_behaves behave, keyboard_modes mode) { @@ -1723,11 +1739,11 @@ namespace api } /// Configures the numeric keyboard. - bool keyboard_numeric(window wd) + bool keyboard_numeric(window wd, bool padding) { internal_scope_guard lock; #ifdef NANA_ENABLE_VIRTUAL_KEYBOARD - return restrict::bedrock.vkeyboard().numeric(wd); + return restrict::bedrock.vkeyboard().numeric(wd, padding); #else (void)wd; return false; diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index ffd2eccea..cfa9f741e 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -92,8 +92,8 @@ namespace nana sz.width -= left_width; sz.height -= 2; graph.rectangle(false, colors::gray_border); - graph.rectangle({ 1, 1, left_width - 2, sz.height }, true, static_cast(0xf6f6f6)); - graph.rectangle({ static_cast(left_width - 1), 1, sz.width, sz.height }, true, colors::white); + graph.rectangle({ 1, 1, left_width - unit, sz.height }, true, static_cast(0xf6f6f6)); + graph.rectangle({ static_cast(left_width - unit), 1, sz.width, sz.height }, true, colors::white); } void item(graph_reference graph, const nana::rectangle& r, const attr& at) override diff --git a/source/paint/pixel_buffer.cpp b/source/paint/pixel_buffer.cpp index ebcdbee2a..574aee5d9 100644 --- a/source/paint/pixel_buffer.cpp +++ b/source/paint/pixel_buffer.cpp @@ -984,7 +984,7 @@ namespace nana{ namespace paint void pixel_buffer::rectangle(const nana::rectangle &r, const ::nana::color& clr, double fade_rate, bool solid) { auto sp = storage_.get(); - if((nullptr == sp) || (fade_rate == 1.0)) return; + if((nullptr == sp) || (fade_rate == 1.0) || r.empty()) return; if (r.right() < 0 || r.x >= static_cast(sp->pixel_size.width) || r.bottom() < 0 || r.y >= static_cast(sp->pixel_size.height)) return;