Merge branch 'hotfixes' of https://github.com/qPCR4vir/nana into qPCR4vir-hotfixes
This commit is contained in:
commit
83ce805d4f
@ -112,6 +112,7 @@ namespace nana
|
|||||||
std::size_t pos_{0};
|
std::size_t pos_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// usefull for both absolute and display (sorted) positions
|
||||||
struct index_pair
|
struct index_pair
|
||||||
{
|
{
|
||||||
size_type cat; //The pos of category
|
size_type cat; //The pos of category
|
||||||
@ -169,6 +170,7 @@ namespace nana
|
|||||||
class drawer_header_impl;
|
class drawer_header_impl;
|
||||||
class drawer_lister_impl;
|
class drawer_lister_impl;
|
||||||
|
|
||||||
|
/// mostly works on display positions
|
||||||
class trigger: public drawer_trigger
|
class trigger: public drawer_trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -198,6 +200,8 @@ namespace nana
|
|||||||
drawer_lister_impl *drawer_lister_;
|
drawer_lister_impl *drawer_lister_;
|
||||||
};//end class trigger
|
};//end class trigger
|
||||||
|
|
||||||
|
/// operate with absolute positions and contain only the position but montain pointers to parts of the real items
|
||||||
|
/// item_proxy self, it references and iterators are not invalidated by sort()
|
||||||
class item_proxy
|
class item_proxy
|
||||||
: public std::iterator<std::input_iterator_tag, item_proxy>
|
: public std::iterator<std::input_iterator_tag, item_proxy>
|
||||||
{
|
{
|
||||||
@ -205,6 +209,13 @@ namespace nana
|
|||||||
item_proxy(essence_t*);
|
item_proxy(essence_t*);
|
||||||
item_proxy(essence_t*, const index_pair&);
|
item_proxy(essence_t*, const index_pair&);
|
||||||
|
|
||||||
|
/// the main porpose of this it to make obvious that item_proxy operate with absolute positions, and dont get moved during sort()
|
||||||
|
static item_proxy from_display(essence_t *ess, const index_pair &relative) ;
|
||||||
|
item_proxy from_display(const index_pair &relative) const;
|
||||||
|
|
||||||
|
/// posible use: last_selected_display = last_selected.to_display().item; use with caution, it get invalidated after a sort()
|
||||||
|
index_pair to_display() const;
|
||||||
|
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
item_proxy & check(bool ck);
|
item_proxy & check(bool ck);
|
||||||
@ -334,7 +345,7 @@ namespace nana
|
|||||||
cat_proxy(essence_t*, size_type pos);
|
cat_proxy(essence_t*, size_type pos);
|
||||||
cat_proxy(essence_t*, category_t*);
|
cat_proxy(essence_t*, category_t*);
|
||||||
|
|
||||||
/// Append an item at end of the category, set_value determines whether assign T object to the value of item.
|
/// Append an item at abs end of the category, set_value determines whether assign T object to the value of item.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
item_proxy append(T&& t, bool set_value = false)
|
item_proxy append(T&& t, bool set_value = false)
|
||||||
{
|
{
|
||||||
@ -367,12 +378,17 @@ namespace nana
|
|||||||
item_proxy cbegin() const;
|
item_proxy cbegin() const;
|
||||||
item_proxy cend() const;
|
item_proxy cend() const;
|
||||||
|
|
||||||
item_proxy at(size_type pos) const;
|
item_proxy at(size_type pos_abs) const;
|
||||||
item_proxy back() const;
|
item_proxy back() const;
|
||||||
|
|
||||||
/// Returns the index of a item by its display pos, the index of the item isn't changed after sorting.
|
/// Returns the absolute index of a item by its display pos, the index of the item isn't changed after sorting.
|
||||||
|
/// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!!
|
||||||
size_type index_by_display_order(size_type disp_order) const;
|
size_type index_by_display_order(size_type disp_order) const;
|
||||||
|
|
||||||
|
/// find display order for the real item but without check from current active sorting, in fact using just the last sorting !!!
|
||||||
size_type display_order(size_type pos) const;
|
size_type display_order(size_type pos) const;
|
||||||
|
|
||||||
|
/// this cat position
|
||||||
size_type position() const;
|
size_type position() const;
|
||||||
|
|
||||||
/// Returns the number of items
|
/// Returns the number of items
|
||||||
@ -410,7 +426,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
essence_t* ess_{nullptr};
|
essence_t* ess_{nullptr};
|
||||||
category_t* cat_{nullptr};
|
category_t* cat_{nullptr};
|
||||||
size_type pos_{0};
|
size_type pos_{0}; ///< Absolute position, not relative to display, and dont change during sort()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
@ -446,12 +462,12 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}//end namespace drawerbase
|
}//end namespace drawerbase
|
||||||
|
|
||||||
/*! \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 items.
|
/*! \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.
|
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 is formed by \a column-fields, each corresponding to one of the \a headers.
|
||||||
An item can be \a selected and \a checked.
|
An item can be \a selected and \a checked.
|
||||||
The user can \a drag the header to \a reisize it or to \a reorganize it.
|
The user can \a drag the header to \a reisize it or to \a reorganize it.
|
||||||
By \a clicking on a header the list get \a reordered, first up, and then down alternatively,
|
By \a clicking on a header the list get \a reordered, first up, and then down alternatively.
|
||||||
*/
|
*/
|
||||||
class listbox
|
class listbox
|
||||||
: public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events, drawerbase::listbox::scheme>,
|
: public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events, drawerbase::listbox::scheme>,
|
||||||
@ -474,6 +490,8 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
|||||||
void auto_draw(bool); ///<Set state: Redraw automatically after an operation?
|
void auto_draw(bool); ///<Set state: Redraw automatically after an operation?
|
||||||
|
|
||||||
void append_header(nana::string, unsigned width = 120);///<Appends a new column with a header text and the specified width at the end
|
void append_header(nana::string, unsigned width = 120);///<Appends a new column with a header text and the specified width at the end
|
||||||
|
listbox& header_width(size_type pos, unsigned pixels);
|
||||||
|
unsigned header_width(size_type pos) const;
|
||||||
|
|
||||||
cat_proxy append(nana::string); ///<Appends a new category at the end
|
cat_proxy append(nana::string); ///<Appends a new category at the end
|
||||||
void append(std::initializer_list<nana::string>); ///<Appends categories at the end
|
void append(std::initializer_list<nana::string>); ///<Appends categories at the end
|
||||||
@ -505,7 +523,7 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
|||||||
return cat_proxy(&_m_ess(), _m_at_key(p));
|
return cat_proxy(&_m_ess(), _m_at_key(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
item_proxy at(const index_pair&) const;
|
item_proxy at(const index_pair &abs_pos) const;
|
||||||
|
|
||||||
void insert(const index_pair&, nana::string); ///<Insert a new item with a text in the first column.
|
void insert(const index_pair&, nana::string); ///<Insert a new item with a text in the first column.
|
||||||
|
|
||||||
@ -534,20 +552,23 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
|||||||
_m_ease_key(&key);
|
_m_ease_key(&key);
|
||||||
}
|
}
|
||||||
|
|
||||||
///Sets a strick weak ordering comparer for a column
|
///Sets a strict weak ordering comparer for a column
|
||||||
void set_sort_compare(size_type col, std::function<bool(const nana::string&, nana::any*,
|
void set_sort_compare(size_type col, std::function<bool(const nana::string&, nana::any*,
|
||||||
const nana::string&, nana::any*, bool reverse)> strick_ordering);
|
const nana::string&, nana::any*, bool reverse)> strick_ordering);
|
||||||
|
|
||||||
|
/// sort() and ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
|
||||||
void sort_col(size_type col, bool reverse = false);
|
void sort_col(size_type col, bool reverse = false);
|
||||||
size_type sort_col() const;
|
size_type sort_col() const;
|
||||||
|
|
||||||
|
/// potencially ivalidate any existing reference from display position to absolute item, that is: after sort() display offset point to different items
|
||||||
void unsort();
|
void unsort();
|
||||||
bool freeze_sort(bool freeze);
|
bool freeze_sort(bool freeze);
|
||||||
|
|
||||||
selection selected() const; ///<Get the indexs of all the selected items
|
selection selected() const; ///<Get the absolute indexs of all the selected items
|
||||||
|
|
||||||
void show_header(bool);
|
void show_header(bool);
|
||||||
bool visible_header() const;
|
bool visible_header() const;
|
||||||
void move_select(bool upwards); ///<Selects an item besides the current selected item.
|
void move_select(bool upwards); ///<Selects an item besides the current selected item in the display.
|
||||||
|
|
||||||
size_type size_categ() const; ///<Get the number of categories
|
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() const; ///<The number of items in the default category
|
||||||
|
@ -49,17 +49,17 @@ namespace nana
|
|||||||
|
|
||||||
struct metrics_type
|
struct metrics_type
|
||||||
{
|
{
|
||||||
typedef std::size_t size_type;
|
using size_type = std::size_t ;
|
||||||
|
|
||||||
size_type peak;
|
size_type peak; ///< the whole total
|
||||||
size_type range;
|
size_type range; ///< how many is shonw on a page, that is, How many to scroll after click on first or second
|
||||||
size_type step;
|
size_type step; ///< how many to scroll by click in forward or backward
|
||||||
size_type value;
|
size_type value; ///< current offset calculated from the very beginnig
|
||||||
|
|
||||||
buttons what;
|
buttons what;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
size_type scroll_length;
|
size_type scroll_length; ///< the lenght in pixels of the central button show how many of the total (peak) is shonw (range)
|
||||||
int scroll_pos;
|
int scroll_pos; ///< in pixels, and correspond to the offsset from the very beginning (value)
|
||||||
int scroll_mouse_offset;
|
int scroll_mouse_offset;
|
||||||
|
|
||||||
metrics_type();
|
metrics_type();
|
||||||
@ -74,7 +74,7 @@ namespace nana
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef nana::paint::graphics& graph_reference;
|
typedef nana::paint::graphics& graph_reference;
|
||||||
const static unsigned fixedsize = 16;
|
const static unsigned fixedsize = 16; // make it part of a new "metric" in the widget_scheme
|
||||||
|
|
||||||
drawer(metrics_type& m);
|
drawer(metrics_type& m);
|
||||||
void set_vertical(bool);
|
void set_vertical(bool);
|
||||||
@ -333,7 +333,7 @@ namespace nana
|
|||||||
|
|
||||||
/// Provides a way to display an object which is larger than the window's client area.
|
/// Provides a way to display an object which is larger than the window's client area.
|
||||||
template<bool Vertical>
|
template<bool Vertical>
|
||||||
class scroll
|
class scroll // add a widget scheme?
|
||||||
: public widget_object<category::widget_tag, drawerbase::scroll::trigger<Vertical>, drawerbase::scroll::scroll_events<Vertical>>
|
: public widget_object<category::widget_tag, drawerbase::scroll::trigger<Vertical>, drawerbase::scroll::scroll_events<Vertical>>
|
||||||
{
|
{
|
||||||
typedef widget_object<category::widget_tag, drawerbase::scroll::trigger<Vertical> > base_type;
|
typedef widget_object<category::widget_tag, drawerbase::scroll::trigger<Vertical> > base_type;
|
||||||
@ -345,29 +345,29 @@ namespace nana
|
|||||||
|
|
||||||
/// \brief The construct that creates a widget.
|
/// \brief The construct that creates a widget.
|
||||||
/// @param wd A handle to the parent window of the widget being created.
|
/// @param wd A handle to the parent window of the widget being created.
|
||||||
/// @param visible specifying the visible after creating.
|
/// @param visible specify the visibility after creation.
|
||||||
scroll(window wd, bool visible)
|
scroll(window wd, bool visible)
|
||||||
{
|
{
|
||||||
this->create(wd, rectangle(), visible);
|
this->create(wd, rectangle(), visible); // add a widget scheme? and take some colors from these wd?
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief The construct that creates a widget.
|
/// \brief The construct that creates a widget.
|
||||||
/// @param wd A handle to the parent window of the widget being created.
|
/// @param wd A handle to the parent window of the widget being created.
|
||||||
/// @param r the size and position of the widget in its parent window coordinate.
|
/// @param r the size and position of the widget in its parent window coordinate.
|
||||||
/// @param visible specifying the visible after creating.
|
/// @param visible specify the visibility after creation.
|
||||||
scroll(window wd, const rectangle& r, bool visible = true)
|
scroll(window wd, const rectangle& r, bool visible = true)
|
||||||
{
|
{
|
||||||
this->create(wd, r, visible);
|
this->create(wd, r, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Determines whether it is scrollable.
|
/// \brief Determines whether it is scrollable.
|
||||||
/// @param for_less whether it can be scrolled for a less value.
|
/// @param for_less whether it can be scrolled for a less value (backward or "up" if true, forward or "down" if false).
|
||||||
bool scrollable(bool for_less) const
|
bool scrollable(bool for_less) const
|
||||||
{
|
{
|
||||||
auto & m = this->get_drawer_trigger().metrics();
|
auto & m = this->get_drawer_trigger().metrics();
|
||||||
return (for_less ? (0 != m.value) : (m.value < m.peak - m.range));
|
return (for_less ? (0 != m.value) : (m.value < m.peak - m.range));
|
||||||
}
|
}
|
||||||
|
/// the whole total (peak)
|
||||||
size_type amount() const
|
size_type amount() const
|
||||||
{
|
{
|
||||||
return this->get_drawer_trigger().metrics().peak;
|
return this->get_drawer_trigger().metrics().peak;
|
||||||
@ -378,7 +378,7 @@ namespace nana
|
|||||||
return this->get_drawer_trigger().peak(Max);
|
return this->get_drawer_trigger().peak(Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the range of the widget.
|
/// Get the range of the widget (how many is shonw on a page, that is, How many to scroll after click on first or second)
|
||||||
size_type range() const
|
size_type range() const
|
||||||
{
|
{
|
||||||
return this->get_drawer_trigger().metrics().range;
|
return this->get_drawer_trigger().metrics().range;
|
||||||
@ -390,7 +390,7 @@ namespace nana
|
|||||||
return this->get_drawer_trigger().range(r);
|
return this->get_drawer_trigger().range(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Get the value.
|
/// \brief Get the value (current offset calculated from the very beginnig)
|
||||||
/// @return the value.
|
/// @return the value.
|
||||||
size_type value() const
|
size_type value() const
|
||||||
{
|
{
|
||||||
@ -419,12 +419,12 @@ namespace nana
|
|||||||
return this->get_drawer_trigger().step(s);
|
return this->get_drawer_trigger().step(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Increase/decrease values by a step.
|
/// \brief Increase/decrease values by a step (alternativelly by some number of steps).
|
||||||
/// @param forward it determines whether increase or decrease.
|
/// @param forward it determines whether increase or decrease.
|
||||||
/// @return true if the value is changed.
|
/// @return true if the value is changed.
|
||||||
bool make_step(bool forward)
|
bool make_step(bool forward, unsigned steps=1)
|
||||||
{
|
{
|
||||||
if(this->get_drawer_trigger().make_step(forward, 1))
|
if(this->get_drawer_trigger().make_step(forward, steps))
|
||||||
{
|
{
|
||||||
API::refresh_window(this->handle());
|
API::refresh_window(this->handle());
|
||||||
return true;
|
return true;
|
||||||
@ -437,13 +437,27 @@ namespace nana
|
|||||||
/// @return true if the vlaue is changed.
|
/// @return true if the vlaue is changed.
|
||||||
bool make_scroll(bool forward)
|
bool make_scroll(bool forward)
|
||||||
{
|
{
|
||||||
if(this->get_drawer_trigger().make_step(forward, 3))
|
if(this->get_drawer_trigger().make_step(forward, 3)) // set this 3 in the metrics of the widget scheme ?
|
||||||
{
|
{
|
||||||
API::refresh_window(this->handle());
|
API::refresh_window(this->handle());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Increase/decrease values by a page as if it is scrolled page up.
|
||||||
|
/// @param forward it determines whether increase or decrease.
|
||||||
|
/// @return true if the vlaue is changed.
|
||||||
|
bool make_page_scroll(bool forward)
|
||||||
|
{
|
||||||
|
if(this->get_drawer_trigger().make_step(forward, range()-1))
|
||||||
|
{
|
||||||
|
API::refresh_window(this->handle());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
};//end class scroll
|
};//end class scroll
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -122,14 +122,14 @@ namespace nana
|
|||||||
if(metrics_.value <= metrics_.range)
|
if(metrics_.value <= metrics_.range)
|
||||||
metrics_.value = 0;
|
metrics_.value = 0;
|
||||||
else
|
else
|
||||||
metrics_.value -= metrics_.range;
|
metrics_.value -= (metrics_.range-1);
|
||||||
}
|
}
|
||||||
else if(buttons::backward == metrics_.what)
|
else if(buttons::backward == metrics_.what)
|
||||||
{
|
{
|
||||||
if(metrics_.peak - metrics_.range - metrics_.value <= metrics_.range)
|
if(metrics_.peak - metrics_.range - metrics_.value <= metrics_.range)
|
||||||
metrics_.value = metrics_.peak - metrics_.range;
|
metrics_.value = metrics_.peak - metrics_.range;
|
||||||
else
|
else
|
||||||
metrics_.value += metrics_.range;
|
metrics_.value += (metrics_.range-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user