label.h

00001 // label.h          -*-c++-*-
00002 
00003 #ifndef LABEL_H
00004 #define LABEL_H
00005 
00006 #include "widget.h"
00007 
00008 namespace cwidget
00009 {
00010   class fragment;
00011   class fragment_cache;
00012 
00013   namespace widgets
00014   {
00024     class label : public widget
00025     {
00026       fragment_cache *txt;
00027     protected:
00028       label(fragment *f);
00029       label(const std::string &_txt, const style &st);
00030       label(const std::string &_txt);
00031       label(const std::wstring &_txt, const style &st);
00032       label(const std::wstring &_txt);
00033 
00034     public:
00035       static util::ref_ptr<label> create(fragment *f)
00036       {
00037         util::ref_ptr<label> rval(new label(f));
00038         rval->decref();
00039         return rval;
00040       }
00041 
00043       static util::ref_ptr<label> create(const std::string &txt, const style &st);
00044 
00046       static util::ref_ptr<label> create(const std::string &txt);
00047 
00049       static util::ref_ptr<label> create(const std::wstring &txt, const style &st);
00050 
00052       static util::ref_ptr<label> create(const std::wstring &txt); 
00053 
00054 
00055       ~label();
00056 
00057       bool get_cursorvisible();
00058       point get_cursorloc();
00059 
00061       int width_request();
00062 
00064       int height_request(int width);
00065 
00066       void paint(const style &st);
00067       void set_text(const std::string &_txt, const style &st);
00068       void set_text(const std::string &_txt);
00069       void set_text(const std::wstring &_txt, const style &st);
00070       void set_text(const std::wstring &_txt);
00071       void set_text(fragment *f);
00072     };
00073 
00074     class transientlabel:public label
00075     // Displays a transient message -- grabs the input focus and vanishes when a
00076     // key is pressed.
00077     {
00078     protected:
00079       virtual bool handle_char(chtype ch);
00080 
00081       transientlabel(const std::string &msg, const style &st)
00082         :label(msg, st)
00083       {
00084       }
00085     public:
00086       static
00087       util::ref_ptr<transientlabel> create(const std::string &msg,
00088                                         const style &st)
00089       {
00090         return new transientlabel(msg, st);
00091       }
00092 
00093       bool focus_me() {return true;}
00094     };
00095 
00096     typedef util::ref_ptr<label> label_ref;
00097 
00098     typedef util::ref_ptr<transientlabel> transientlabel_ref;
00099   }
00100 }
00101 
00102 #endif

Generated on Fri Feb 8 12:54:56 2008 for cwidget by  doxygen 1.5.4