qPCR4vir ae3c9f6357 Fix: Workaround label constructor selecting bool instead nana::string when called with nana::char_t* which silently brake a lot of code
Maybe there are more elegant solutions... The second constructor was eliminated in:

Commit: f4924ef2f8600fafa82d3fc0d1c4d5f9eea0c738 [f4924ef]
Parents: e0ee42d184
Author: Jinhao <cnjinhao@hotmail.com>
Date: Sonntag, 2. August 2015 19:37:36
Labels: develop
add throw() for some functions
2015-08-06 16:44:21 +02:00

83 lines
2.6 KiB
C++

/**
* A Label Control Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 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/gui/widgets/label.hpp
*/
#ifndef NANA_GUI_WIDGET_LABEL_HPP
#define NANA_GUI_WIDGET_LABEL_HPP
#include "widget.hpp"
namespace nana
{
namespace drawerbase
{
namespace label
{
enum class command /// Defines the event type for format listener.
{
enter, leave, click
};
/// draw the label
class trigger: public drawer_trigger
{
public:
struct impl_t;
trigger();
~trigger();
impl_t * impl() const;
private:
void attached(widget_reference, graph_reference) override;
void refresh(graph_reference) override;
void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_leave(graph_reference, const arg_mouse&) override;
void click(graph_reference, const arg_click&) override;
private:
impl_t * impl_;
};
}//end namespace label
}//end namespace drawerbase
class label
: public widget_object<category::widget_tag, drawerbase::label::trigger>
{
label(const label&) = delete;
label(label&&) = delete;
public:
typedef drawerbase::label::command command;
label();
label(window, bool visible);
label(window, const nana::string& text, bool visible = true);
label(window parent, const nana::char_t* text, bool visible = true) :label(parent, nana::string(text),visible) {};
label(window, const rectangle& = {}, bool visible = true);
label& transparent(bool); ///< Switchs the label widget to the transparent background mode.
bool transparent() const throw();
label& format(bool); ///< Switches the format mode of the widget.
label& add_format_listener(std::function<void(command, const nana::string&)>);
label& click_for(window associated_window) throw(); // as same as the "for" attribute of a label
/// Returns the size of the text. If *allowed_width_in_pixel* is not zero, returns a
/// "corrected" size that changes lines to fit the text into the specified width
nana::size measure(unsigned allowed_width_in_pixel) const;
static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
private:
//Overrides widget's virtual function
void _m_caption(nana::string&&) override;
};
}//end namespace nana
#endif