Merge branch 'hotfix-1.3' of https://github.com/qPCR4vir/nana into qPCR4vir-hotfix-1.3
This commit is contained in:
@@ -46,7 +46,31 @@ namespace nana
|
||||
class charset_encoding_interface;
|
||||
}
|
||||
|
||||
/// An intelligent charset class for character code conversion.
|
||||
/*!\class charset
|
||||
\brief An intelligent charset class for character code conversion.
|
||||
Example:
|
||||
1. A UTF-8 string from the socket.
|
||||
|
||||
int len = ::recv(sd, buf, buflen, 0);
|
||||
textbox.caption(nana::charset(std::string(buf, len), nana::unicode::utf8));
|
||||
|
||||
2. Send the string in text to the socket as UTF-8.
|
||||
|
||||
std::string utf8str = nana::charset(textbox.caption()).to_bytes(nana::unicode::utf8);
|
||||
::send(sd, utf8str.c_str(), utf8str.size(), 0);
|
||||
|
||||
3, Convert a string to the specified multi-byte character code.
|
||||
|
||||
// Convert to a multibytes string through default system language.
|
||||
std::string mbstr = nana::charset(a_wstring);
|
||||
|
||||
// If the default system language is English and convert
|
||||
// a Chinese unicode string to multibytes string through GB2312
|
||||
std::setlocale(LC_CTYPE, "zh_CN.GB2312");
|
||||
//set::setlocale(LC_CTYPE, ".936"); call it in Windows
|
||||
std::string mbstr = nana::charset(a_wstring_with_chinese);
|
||||
|
||||
*/
|
||||
class charset
|
||||
{
|
||||
public:
|
||||
@@ -74,27 +98,3 @@ namespace nana
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
/*!\class charset
|
||||
|
||||
Example
|
||||
1. A UTF-8 string from the socket.
|
||||
|
||||
int len = ::recv(sd, buf, buflen, 0);
|
||||
textbox.caption(nana::charset(std::string(buf, len), nana::unicode::utf8));
|
||||
|
||||
2. Send the string in text to the socket as UTF-8.
|
||||
|
||||
std::string utf8str = nana::charset(textbox.caption()).to_bytes(nana::unicode::utf8);
|
||||
::send(sd, utf8str.c_str(), utf8str.size(), 0);
|
||||
|
||||
3, Convert a string to the specified multi-byte character code.
|
||||
|
||||
//Convert to a multibytes string through default system language.
|
||||
std::string mbstr = nana::charset(a_wstring);
|
||||
//If the default system language is English and convert
|
||||
//a Chinese unicode string to multibytes string through GB2312
|
||||
std::setlocale(LC_CTYPE, "zh_CN.GB2312");
|
||||
//set::setlocale(LC_CTYPE, ".936"); call it in Windows
|
||||
std::string mbstr = nana::charset(a_wstring_with_chinese);
|
||||
|
||||
*/
|
||||
@@ -114,12 +114,29 @@ namespace std
|
||||
|
||||
namespace nana
|
||||
{
|
||||
/// move to *.h ??
|
||||
struct utf8_Error : std::runtime_error
|
||||
{
|
||||
static bool use_throw; ///< def { true }; use carefully - it is a global variable !! \todo initialize from a #define ?
|
||||
|
||||
using std::runtime_error::runtime_error;
|
||||
|
||||
void emit();
|
||||
};
|
||||
|
||||
|
||||
/// Checks whether a specified text is utf8 encoding
|
||||
bool is_utf8(const char* str, unsigned len);
|
||||
void throw_not_utf8(const std::string& text);
|
||||
void throw_not_utf8(const char*, unsigned len);
|
||||
void throw_not_utf8(const char*);
|
||||
|
||||
/// this text needed change, it needed review ??
|
||||
bool review_utf8(const std::string& text);
|
||||
|
||||
/// this text needed change, it needed review ??
|
||||
bool review_utf8(std::string& text);
|
||||
|
||||
const std::string& to_utf8(const std::string&);
|
||||
std::string to_utf8(const std::wstring&);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
/**
|
||||
* Selector of Platform Specification
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* 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/detail/platform_spec_selector.hpp
|
||||
* @file nana/detail/platform_spec_selector.hpp
|
||||
*
|
||||
* Selects the proper platform_spec header file for the current platform
|
||||
* @brief Selects the proper platform_spec header file for the current platform
|
||||
*/
|
||||
|
||||
#include <nana/config.hpp>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/**
|
||||
* A Basic Window Widget Definition
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
@@ -7,7 +7,8 @@
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/detail/basic_window.hpp
|
||||
* @file nana/gui/detail/basic_window.hpp
|
||||
* @brief A Basic Window Widget Definition
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
||||
@@ -58,20 +59,18 @@ namespace detail
|
||||
::nana::rectangle effective_range_;
|
||||
};//end class caret_descriptor
|
||||
|
||||
//tab_type
|
||||
//@brief: Define some constant about tab category, these flags can be combine with operator |
|
||||
/// Define some constant about tab category, these flags can be combine with operator |
|
||||
struct tab_type
|
||||
{
|
||||
enum t
|
||||
{
|
||||
none, //process by nana
|
||||
tabstop, //move to the next tabstop window
|
||||
eating, //process by current window
|
||||
none, ///< process by nana
|
||||
tabstop, ///< move to the next tabstop window
|
||||
eating, ///< process by current window
|
||||
};
|
||||
};
|
||||
|
||||
//struct basic_window
|
||||
//@brief: a window data structure descriptor
|
||||
/// a window data structure descriptor
|
||||
struct basic_window
|
||||
: public events_holder
|
||||
{
|
||||
@@ -88,8 +87,7 @@ namespace detail
|
||||
bool rendered;
|
||||
};
|
||||
|
||||
//basic_window
|
||||
//@brief: constructor for the root window
|
||||
/// constructor for the root window
|
||||
basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&&, category::root_tag**);
|
||||
|
||||
template<typename Category>
|
||||
@@ -106,8 +104,7 @@ namespace detail
|
||||
|
||||
~basic_window();
|
||||
|
||||
//bind_native_window
|
||||
//@brief: bind a native window and baisc_window
|
||||
/// bind a native window and baisc_window
|
||||
void bind_native_window(native_window_type, unsigned width, unsigned height, unsigned extra_width, unsigned extra_height, paint::graphics&);
|
||||
|
||||
void frame_window(native_window_type);
|
||||
@@ -116,13 +113,13 @@ namespace detail
|
||||
bool visible_parents() const;
|
||||
bool displayed() const;
|
||||
bool belong_to_lazy() const;
|
||||
const basic_window * child_caret() const; //Returns a child which owns a caret
|
||||
const basic_window * child_caret() const; ///< Returns the child which owns the caret
|
||||
|
||||
bool is_draw_through() const; ///< Determines whether it is a draw-through window.
|
||||
|
||||
basic_window * seek_non_lite_widget_ancestor() const;
|
||||
public:
|
||||
//Override event_holder
|
||||
/// Override event_holder
|
||||
bool set_events(const std::shared_ptr<general_events>&) override;
|
||||
general_events * get_events() const override;
|
||||
private:
|
||||
@@ -132,7 +129,7 @@ namespace detail
|
||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
||||
point pos_native;
|
||||
#endif
|
||||
point pos_root; //coordinate for root window
|
||||
point pos_root; ///< coordinates of the root window
|
||||
point pos_owner;
|
||||
size dimension;
|
||||
::nana::size min_track_size;
|
||||
@@ -147,9 +144,9 @@ namespace detail
|
||||
basic_window *owner;
|
||||
|
||||
native_string_type title;
|
||||
::nana::detail::drawer drawer; //Self Drawer with owen graphics
|
||||
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||
paint::graphics* root_graph; //Refer to the root buffer graphics
|
||||
::nana::detail::drawer drawer; ///< Self Drawer with owen graphics
|
||||
basic_window* root_widget; ///< A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||
paint::graphics* root_graph; ///< Refer to the root buffer graphics
|
||||
cursor predef_cursor;
|
||||
std::unique_ptr<widget_notifier_interface> widget_notifier;
|
||||
|
||||
@@ -157,20 +154,20 @@ namespace detail
|
||||
{
|
||||
bool enabled :1;
|
||||
bool dbl_click :1;
|
||||
bool captured :1; //if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
||||
bool captured :1; ///< if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
||||
bool modal :1;
|
||||
bool take_active:1; //If take_active is false, other.active_window still keeps the focus.
|
||||
bool take_active:1; ///< If take_active is false, other.active_window still keeps the focus.
|
||||
bool refreshing :1;
|
||||
bool destroying :1;
|
||||
bool dropable :1; //Whether the window has make mouse_drop event.
|
||||
bool fullscreen :1; //When the window is maximizing whether it fit for fullscreen.
|
||||
bool dropable :1; ///< Whether the window has make mouse_drop event.
|
||||
bool fullscreen :1; ///< When the window is maximizing whether it fit for fullscreen.
|
||||
bool borderless :1;
|
||||
bool make_bground_declared : 1; //explicitly make bground for bground effects
|
||||
bool ignore_menubar_focus : 1; //A flag indicates whether the menubar sets the focus.
|
||||
bool ignore_mouse_focus : 1; //A flag indicates whether the widget accepts focus when clicking on it
|
||||
bool space_click_enabled : 1; //A flag indicates whether enable mouse_down/click/mouse_up when pressing and releasing whitespace key.
|
||||
bool make_bground_declared : 1; ///< explicitly make bground for bground effects
|
||||
bool ignore_menubar_focus : 1; ///< A flag indicates whether the menubar sets the focus.
|
||||
bool ignore_mouse_focus : 1; ///< A flag indicates whether the widget accepts focus when clicking on it
|
||||
bool space_click_enabled : 1; ///< A flag indicates whether enable mouse_down/click/mouse_up when pressing and releasing whitespace key.
|
||||
unsigned Reserved :18;
|
||||
unsigned char tab; //indicate a window that can receive the keyboard TAB
|
||||
unsigned char tab; ///< indicate a window that can receive the keyboard TAB
|
||||
mouse_action action;
|
||||
}flags;
|
||||
|
||||
@@ -199,7 +196,7 @@ namespace detail
|
||||
|
||||
struct attr_root_tag
|
||||
{
|
||||
container frames; //initialization is null, it will be created while creating a frame widget. Refer to WindowManager::create_frame
|
||||
container frames; ///< initialization is null, it will be created while creating a frame widget. Refer to WindowManager::create_frame
|
||||
container tabstop;
|
||||
std::vector<edge_nimbus_action> effects_edge_nimbus;
|
||||
basic_window* focus{nullptr};
|
||||
@@ -211,13 +208,13 @@ namespace detail
|
||||
cursor state_cursor{nana::cursor::arrow};
|
||||
basic_window* state_cursor_window{ nullptr };
|
||||
|
||||
std::function<void()> draw_through; // A draw through renderer for root widgets.
|
||||
std::function<void()> draw_through; ///< A draw through renderer for root widgets.
|
||||
};
|
||||
|
||||
const category::flags category;
|
||||
basic_window *active_window; //if flags.take_active is false, the active_window still keeps the focus,
|
||||
//if the active_window is null, the parent of this window keeps focus.
|
||||
paint::graphics glass_buffer; //if effect.bground is avaiable. Refer to window_layout::make_bground.
|
||||
basic_window *active_window; ///< if flags.take_active is false, the active_window still keeps the focus,
|
||||
///< if the active_window is null, the parent of this window keeps focus.
|
||||
paint::graphics glass_buffer; ///< if effect.bground is avaiable. Refer to window_layout::make_bground.
|
||||
update_state upd_state;
|
||||
|
||||
union
|
||||
@@ -230,8 +227,8 @@ namespace detail
|
||||
~other_tag();
|
||||
}other;
|
||||
|
||||
native_window_type root; //root Window handle
|
||||
unsigned thread_id; //the identifier of the thread that created the window.
|
||||
native_window_type root; ///< root Window handle
|
||||
unsigned thread_id; ///< the identifier of the thread that created the window.
|
||||
unsigned index;
|
||||
container children;
|
||||
};
|
||||
|
||||
@@ -538,7 +538,7 @@ namespace nana
|
||||
struct arg_click : public event_arg
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
const arg_mouse* mouse_args; ///< If it is not null, it refers to the mouse arguments for click event emitted by mouse, nullptr otherwise.
|
||||
const arg_mouse* mouse_args{}; ///< If it is not null, it refers to the mouse arguments for click event emitted by mouse, nullptr otherwise.
|
||||
};
|
||||
|
||||
/// provides some fundamental events that every widget owns.
|
||||
|
||||
@@ -297,7 +297,18 @@ namespace nana
|
||||
throw std::runtime_error("listbox::item_proxy.value<T>() invalid type of value");
|
||||
return *p;
|
||||
}
|
||||
template<typename T>
|
||||
T & value()
|
||||
{
|
||||
auto * pany = _m_value();
|
||||
if (nullptr == pany)
|
||||
throw std::runtime_error("listbox::item_proxy.value<T>() is empty");
|
||||
|
||||
T * p = any_cast<T>(_m_value(false));
|
||||
if (nullptr == p)
|
||||
throw std::runtime_error("listbox::item_proxy.value<T>() invalid type of value");
|
||||
return *p;
|
||||
}
|
||||
template<typename T>
|
||||
item_proxy & value(T&& t)
|
||||
{
|
||||
@@ -506,7 +517,7 @@ namespace nana
|
||||
basic_event<arg_listbox> checked;
|
||||
basic_event<arg_listbox> selected;
|
||||
|
||||
/// An event occurs when a listbox category is double clicking.
|
||||
/// An event that occurs when a listbox category is double clicking.
|
||||
basic_event<arg_category> category_dbl_click;
|
||||
};
|
||||
|
||||
@@ -518,26 +529,40 @@ namespace nana
|
||||
color_proxy header_floated{ static_cast<color_rgb>(0xBABBBC)};
|
||||
color_proxy item_selected{ static_cast<color_rgb>(0xD5EFFC) };
|
||||
|
||||
unsigned max_header_width{3000}, /// \todo how to implement some geometrical parameters ??
|
||||
ext_w = 5;
|
||||
/// \todo how to implement some geometrical parameters ??
|
||||
unsigned max_header_width{ 3000 }; ///< during auto width don't alow more than this
|
||||
unsigned min_header_width{ 20 }; ///< non counting suspension_width
|
||||
unsigned suspension_width{ 0 }; ///< the trigger will set this to the width if ("...")
|
||||
unsigned ext_w { 5 }; ///< ??
|
||||
unsigned header_height { 20 }; ///< header height header_size
|
||||
unsigned text_height { 0 }; ///< the trigger will set this to the height of the text font
|
||||
unsigned item_height_ex { 6 }; ///< 6? item_height = text_height + item_height_ex
|
||||
unsigned item_height { 0 }; ///< the trigger will set this TO item_height = text_height + item_height_ex
|
||||
unsigned header_mouse_spliter_area_before{ 2 };
|
||||
unsigned header_mouse_spliter_area_after { 3 };
|
||||
|
||||
};
|
||||
}
|
||||
}//end namespace drawerbase
|
||||
|
||||
/*! \class listbox
|
||||
\brief A rectangle containing a list of strings from which the user can select. This widget contain a list of \a categories, with in turn contain a list of \a items.
|
||||
A category is a text with can be \a selected, \a checked and \a expanded to show the items.
|
||||
An item is formed by \a column-fields, each corresponding to one of the \a headers.
|
||||
An item can be \a selected and \a checked.
|
||||
\brief A rectangle containing a list of strings from which the user can select.
|
||||
This widget contain a list of \a categories, with in turn contain a list of \a items.
|
||||
A \a category is a text with can be \a selected, \a checked and \a expanded to show the \a items.
|
||||
An \a item is formed by \a column-fields, each corresponding to one of the \a headers.
|
||||
An \a item can be \a selected and \a checked.
|
||||
The user can \a drag the header to \a resize it or to \a reorganize it.
|
||||
By \a clicking on one header the list get \a reordered, first up, and then down alternatively.
|
||||
|
||||
1. The resolver is used to resolute an object of the specified type for a listbox item.
|
||||
3. nana::listbox creates the category 0 by default. The member functions without the categ parameter operate the items that belong to category 0.
|
||||
1. The resolver is used to resolute an object of the specified type into (or back from) a listbox item.
|
||||
3. nana::listbox creates the category 0 by default.
|
||||
This is an special category, becouse it is invisible, while the associated items are visible.
|
||||
The optional, user-created categories begin at index 1 and are visibles.
|
||||
The member functions without the categ parameter operate the items that belong to category 0.
|
||||
4. A sort compare is used for sorting the items. It is a strict weak ordering comparer that must meet the requirement:
|
||||
Irreflexivity (comp(x, x) returns false)
|
||||
and
|
||||
antisymmetry(comp(a, b) != comp(b, a) returns true)
|
||||
Antisymmetry(comp(a, b) != comp(b, a) returns true)
|
||||
A simple example.
|
||||
bool sort_compare( const std::string& s1, nana::any*,
|
||||
const std::string& s2, nana::any*, bool reverse)
|
||||
@@ -552,10 +577,10 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
{
|
||||
if(o1 && o2) //some items may not attach a customer object.
|
||||
{
|
||||
int * i1 = o1->get<int>();
|
||||
int * i2 = o2->get<int>();
|
||||
int * i1 = any_cast<int>(*o1);
|
||||
int * i2 = any_cast<int>(*o2);
|
||||
return (i1 && i2 && (reverse ? *i1 > *i2 : *i1 < *i2));
|
||||
;//some types may not be int.
|
||||
// ^ some types may not be int.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -699,7 +724,7 @@ By \a clicking on one header the list get \a reordered, first up, and then down
|
||||
|
||||
size_type size_categ() const; ///<Get the number of categories
|
||||
size_type size_item() const; ///<The number of items in the default category
|
||||
size_type size_item(size_type cat) const; ///<The number of items in category "cat"
|
||||
size_type size_item(size_type cat) const; ///<The number of items in category "cat"
|
||||
|
||||
void enable_single(bool for_selection, bool category_limited);
|
||||
void disable_single(bool for_selection);
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace nana
|
||||
};
|
||||
}//end namespace slider
|
||||
}//end namespace drawerbase
|
||||
/// A slider widget wich the user can drag for tracking
|
||||
/// A slider widget wich the user can drag for tracking \todo add scheme ?
|
||||
class slider
|
||||
: public widget_object<category::widget_tag, drawerbase::slider::trigger, drawerbase::slider::slider_events>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user