1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
// -*- mode: c++ -*-
//
// This file is part of libyacurs.
// Copyright (C) 2013 Rafael Ostertag
//
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see
// <http://www.gnu.org/licenses/>.
//
//
// $Id$
#ifndef LABEL_H
#define LABEL_H 1
#include <string>
#include "widget.h"
namespace YACURS {
/**
* Display text on the screen.
*
* Simple widget for displaying text on the screen.
*
* Label is not dynamic, i.e. if the text is too long, it might happen
* that it cannot be realized() and throwing an exception.
*/
class Label : public Widget {
private:
COLOROBJ _color;
/**
* Length of label.
*
* @returns length of label, if compiled with YACURS_USE_WCHAR
* defined, takes MB characters into account.
*/
size_t label_length() const;
protected:
/**
* The text to be displayed.
*/
std::string _label;
/**
* The size the Label requires. Rows are always 1. Cols are
* _label.length(). Derrived classes may define other
* constraints.
*/
Size _size;
public:
/**
* Constructor.
*
* @param l label
*/
Label(const std::string& l = std::string());
Label& operator=(const Label&) = delete;
Label& operator=(Label&&) = delete;
Label(const Label&) = delete;
Label(Label&&) = delete;
virtual ~Label();
virtual void label(const std::string& l);
virtual const std::string& label() const;
void color(COLOROBJ c);
COLOROBJ color() const;
// From WidgetBase
/**
* Size the Label requires.
*
* @return Size::rows() always 1. Size::cols() equal the
* length of the string to be displayed.
*/
Size size() const;
Size size_hint() const;
/**
* Dummy. Does nothing.
*
* Label is not a container Widget, hence it may not notified
* of size changes().
*
* @return always @false
*/
bool size_change();
/**
* Does nothing.
*
* Does nothing on a Label, but we have to override.
*/
void reset_size();
// From Realizeable
/**
* Refresh the label.
*
* Adds the Label text to the subwin.
*
* @param immediate not directly used by Label::refresh() but
* passed to Widget::refresh().
*/
void refresh(bool immediate);
};
} // namespace YACURS
#endif // LABEL_H
|