1 /* text.h
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2001-2014 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef TEXT_H
23 #define TEXT_H
24 
25 #include "aguixdefs.h"
26 #include "guielement.h"
27 #include "textshrinker.hh"
28 #include <string>
29 #include "refcount.hh"
30 
31 class Text:public GUIElement {
32 public:
33   Text( class AGUIX *aguix, int x, int y, const char *text, int fg, int bg );
34   Text( class AGUIX *aguix, int x, int y, const char *text );
35 
36   virtual ~Text();
37   Text( const Text &other );
38   Text &operator=( const Text &other );
39   const char *getText() const;
40   void setText(const char *);
41   int getColor() const;
42   void setColor(int color);
43   virtual void redraw();
44   virtual void flush();
45   virtual bool handleMessage(XEvent *E,Message *msg);
46   int setFont( const char * );
47   virtual const char *getType() const;
48   virtual bool isType(const char *type) const;
49   void setBG( int color );
50   int getBG() const;
51   void setFG( int color );
52   int getFG() const;
53 
54   void setTextShrinker( RefCount<TextShrinker> shrinker );
55 private:
56   char *text;
57   int color, bg;
58   bool bgset, ownbg;
59   class AGUIXFont *font;
60   static const char *type;
61   RefCount<TextShrinker> m_shrinker;
62   struct {
63       std::string current_text;
64       int current_width;
65   } m_shrinker_buf;
66 };
67 
68 #endif
69