Represent an architecture of categories and what category is chosen. The categorize widget can be used for representing a path of a directory or the order of a hierarchy.
More...
|
| categorize () |
|
this | create (wd, r, visible) |
|
| categorize (window wd, bool visible) |
|
| categorize (window wd, const std::string &text_utf8, bool visible=true) |
|
| categorize (window wd, const char *text_utf8, bool visible=true) |
|
| categorize (window wd, const std::wstring &text, bool visible=true) |
|
| categorize (window wd, const wchar_t *text, bool visible=true) |
|
categorize & | insert (const std::string &name, const value_type &value) |
|
categorize & | childset (const std::string &name, const value_type &value) |
| Inserts a child category into current category. More...
|
|
categorize & | childset_erase (const std::string &name) |
| Erases a child category with a specified name from current category. More...
|
|
void | clear () |
|
categorize & | splitstr (const std::string &sstr) |
| Sets the splitter string. More...
|
|
std::string | splitstr () const |
|
value_type & | value () const |
| Retrieves a reference of the current category's value type object. If current category is empty, it throws a exception of std::runtime_error. More...
|
|
| widget_object () |
|
| ~widget_object () |
|
event_type & | events () const |
|
bool | create (window parent_wd, bool visible) |
|
bool | create (window parent_wd, const rectangle &r={}, bool visible=true) |
|
widget_object & | borderless (bool enable) |
|
bool | borderless () const |
|
scheme_type & | scheme () const |
|
void | filter_event (const event_code evt_code, const bool bDisabled) |
|
void | filter_event (const std::vector< event_code > evt_codes, const bool bDisabled) |
|
void | filter_event (const event_filter_status &evt_all_states) |
|
bool | filter_event (const event_code evt_code) |
|
event_filter_status | filter_event () |
|
void | clear_filter () |
|
window | handle () const override |
| Returns the handle of window, returns 0 if window is not created. More...
|
|
| widget ()=default |
|
virtual | ~widget ()=default |
|
bool | empty () const |
| Determines whether the manipulator is handling a window. More...
|
|
void | close () |
|
window | parent () const |
|
::std::string | caption () const noexcept |
|
::std::wstring | caption_wstring () const noexcept |
|
native_string_type | caption_native () const noexcept |
|
widget & | caption (std::string utf8) |
|
widget & | caption (std::wstring) |
|
template<typename... Args> |
void | i18n (std::string msgid, Args &&...args) |
|
void | i18n (i18n_eval) |
|
void | cursor (nana::cursor) |
|
nana::cursor | cursor () const |
| Retrieves the shape of cursor. More...
|
|
void | typeface (const paint::font &font) |
|
paint::font | typeface () const |
|
bool | enabled () const |
| Determines whether the window is enabled for mouse and keyboard input. More...
|
|
void | enabled (bool) |
|
void | enable_dropfiles (bool) |
| Enables/Disables a window to accept dropped files. More...
|
|
void | focus () |
|
bool | focused () const |
|
std::shared_ptr
< scroll_operation_interface > | scroll_operation () |
|
void | show () |
| Sets the window visible. More...
|
|
void | hide () |
| Sets the window invisible. More...
|
|
bool | visible () const |
|
nana::size | size () const |
|
void | size (const nana::size &) |
|
void | set_capture (bool ignore_children) |
| Enables the widget to grab the mouse input. More...
|
|
void | release_capture () |
| Disables the widget to grab the mouse input. More...
|
|
point | pos () const |
|
void | move (int x, int y) |
|
void | move (const point &) |
|
void | move (const rectangle &) |
|
void | fgcolor (const nana::color &) |
|
nana::color | fgcolor () const |
|
void | bgcolor (const nana::color &) |
|
nana::color | bgcolor () const |
|
general_events & | events () const |
|
void | umake_event (event_handle eh) const |
| Deletes an event callback by a handle. More...
|
|
widget & | register_shortkey (wchar_t) |
| Registers a shortkey. To remove a registered key, pass 0. More...
|
|
widget & | take_active (bool activated, window take_if_not_activated) |
|
widget & | tooltip (const ::std::string &) |
|
| operator dummy_bool_type () const |
|
| operator window () const |
|
template<typename T>
class nana::categorize< T >
Represent an architecture of categories and what category is chosen. The categorize widget can be used for representing a path of a directory or the order of a hierarchy.
- The definition of ext_event_type
struct ext_event_type
{
typedef Implementation-Specified categorize_type;
typedef typename categorize_type::value_type value_type;
nana::functor_group<void(categorize_type&, value_type&)> selected; //Selects a category
};
- Definition of renderer
class renderer
{
public:
typedef nana::paint::graphics & graph_reference;
enum state_t {state_normal, state_over, state_pressed};
struct ui_element
{
enum t
{
none, //Out of the widget
somewhere, item_root, item_name, item_arrow
};
static const size_t npos = static_cast<size_t>(-1);
t what;
size_t index;
ui_element();
};
virtual ~renderer() = 0;
virtual void background(graph_reference, window, const nana::rectangle&,
const ui_element&) = 0;
virtual void root_arrow(graph_reference, const nana::rectangle&, state_t) = 0;
virtual void item(graph_reference, const nana::rectangle&, size_t index,
const nana::string& name, unsigned text_height,
bool has_child, state_t) = 0;
virtual void border(graph_reference) = 0;
};
- The caption() methods of the categorize widget is used for retrieving and setting the category.
example
#include <iostream>
#include <nana/gui/wvl.hpp>
#include <nana/gui/widgets/categorize.hpp>
void selected(nana::categorize<int> & categ, int&)
{
nana::msgbox mb(categ, STR("categorize"));
mb.icon(mb.icon_information);
mb<<STR("The value of selected is ")<<categ.value()<<STR(", caption is \"")
<<categ.caption()<<STR("\""); //caption() method, see Note 3.
mb();
}
int main()
{
using namespace nana::gui;
form fm;
categorize<int> categ(fm, 10, 10, 200, 24);
categ.childset(STR("Invalid Category"), 0); // Invalid category because of empty current category.
categ.insert(STR("First"), 0); // Insert a category and now it is the current category.
categ.insert(STR("Second"), 1); // Insert a category as a child of "First" category, and then
; // the "Second" is the current category.
categ.childset(STR("Third"), 2);
; // Insert a category as a child of "Second".
categ.childset(STR("Another Child"), 2);
; // childset() always insert categories into current category, and
; // it does not displace the current category, and therefore "Another Child"
; // is a child of "Second".
categ.ext_event().selected = selected;
; // This may crash in VC2012-RC due to compiler bug.
; // Please refer to compatibility-issue for more details
fm.show();
exec();
}
Screenshot of categorize.
- Examples:
- categ.cpp, file_explorer.cpp, widget_show.cpp, and widget_show2.cpp.