Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cnjinhao committed May 15, 2024
1 parent 142c985 commit eb391cb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
11 changes: 8 additions & 3 deletions include/nana/gui/programming_interface.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Nana GUI Programming Interface Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2023 Jinhao([email protected])
* Copyright(C) 2003-2024 Jinhao([email protected])
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -133,7 +133,10 @@ namespace api

std::optional<upoint> 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


Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down
24 changes: 20 additions & 4 deletions source/gui/programming_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Nana GUI Programming Interface Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2023 Jinhao([email protected])
* Copyright(C) 2003-2024 Jinhao([email protected])
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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<std::string> langs, keyboard_behaves behave, keyboard_modes mode)
{
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions source/gui/widgets/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<color_rgb>(0xf6f6f6));
graph.rectangle({ static_cast<int>(left_width - 1), 1, sz.width, sz.height }, true, colors::white);
graph.rectangle({ 1, 1, left_width - unit, sz.height }, true, static_cast<color_rgb>(0xf6f6f6));
graph.rectangle({ static_cast<int>(left_width - unit), 1, sz.width, sz.height }, true, colors::white);
}

void item(graph_reference graph, const nana::rectangle& r, const attr& at) override
Expand Down
2 changes: 1 addition & 1 deletion source/paint/pixel_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(sp->pixel_size.width) || r.bottom() < 0 || r.y >= static_cast<int>(sp->pixel_size.height))
return;
Expand Down

0 comments on commit eb391cb

Please sign in to comment.