label.h

Go to the documentation of this file.
00001 /*
00002   libwt - Vassilis Virvilis Toolkit - a widget library
00003   Copyright (C) 2006 Vassilis Virvilis <vasvir2@fastmail.fm>
00004  
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the
00017   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018   Boston, MA  02111-1307, SA.
00019 */
00020 
00021 #ifndef WT_LABEL_H
00022 #define WT_LABEL_H
00023 
00024 #include <wt/frame.h>
00025 
00026 namespace Wt {
00027 
00028 /// Display a text or pixmap message on screen
00029 class Label : public Frame {
00030 public:
00031     Label(Widget *parent = 0,
00032           const std::string& name = "Label::anon", int wflags = 0);
00033     Label(const std::string& text, Widget *parent = 0,
00034           const std::string& name = "Label::anon", int wflags = 0);
00035 
00036     const std::string text() const {
00037         return text_;
00038     }
00039 
00040     const Pixmap& pixmap() const {
00041         return pixmap_;
00042     }
00043 
00044     virtual void setText(const std::string& text);
00045     virtual void setPixmap(const Pixmap& pixmap);
00046     virtual void setNum(int num);
00047     virtual void setNum(double num);
00048     void clear();
00049 
00050     WVar<int> alignment;
00051     WVar<int> indent;
00052     WVar<bool> scaledContents;
00053 
00054 protected:
00055     int effectiveIndent() const;
00056     virtual void drawContents(Painter *p);
00057 
00058     //reimplementation from Widget::update()
00059     void update();
00060 
00061     virtual void fontChange(const Font& old_font);
00062 
00063 private:
00064     Pixmap pixmap_;
00065     std::string text_;
00066 
00067     // helpers
00068     void init();
00069     Size calc_size_hint() const;
00070 };
00071 
00072 } // namepspace wt
00073 
00074 #endif // WT_LABEL_H

Generated Fri Jul 28 19:23:00 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.