1 | // |
---|
2 | // "$Id: Symbol.h 4303 2005-05-01 03:33:52Z spitzak $" |
---|
3 | // |
---|
4 | // The fltk drawing library |
---|
5 | // |
---|
6 | // Copyright 1998-2003 by Bill Spitzak and others. |
---|
7 | // |
---|
8 | // This library is free software; you can redistribute it and/or |
---|
9 | // modify it under the terms of the GNU Library General Public |
---|
10 | // License as published by the Free Software Foundation; either |
---|
11 | // version 2 of the License, or (at your option) any later version. |
---|
12 | // |
---|
13 | // This library is distributed in the hope that it will be useful, |
---|
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | // Library General Public License for more details. |
---|
17 | // |
---|
18 | // You should have received a copy of the GNU Library General Public |
---|
19 | // License along with this library; if not, write to the Free Software |
---|
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
21 | // USA. |
---|
22 | // |
---|
23 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
24 | // |
---|
25 | |
---|
26 | #ifndef fltk_Symbol_h |
---|
27 | #define fltk_Symbol_h |
---|
28 | |
---|
29 | #include "FL_API.h" |
---|
30 | #include "Color.h" |
---|
31 | #include "Rectangle.h" |
---|
32 | #include "PixelType.h" |
---|
33 | |
---|
34 | namespace fltk { |
---|
35 | |
---|
36 | class Style; |
---|
37 | |
---|
38 | class FL_API Symbol { |
---|
39 | const char* name_; |
---|
40 | static const char* text_; |
---|
41 | |
---|
42 | // Forbid use of copy contructor and assign operator |
---|
43 | Symbol & operator=(const Symbol &); |
---|
44 | Symbol(const Symbol &); |
---|
45 | |
---|
46 | public: |
---|
47 | |
---|
48 | Symbol(const char* name=0); |
---|
49 | const char* name() const {return name_;} |
---|
50 | void name(const char*); |
---|
51 | |
---|
52 | virtual void _measure(int& w, int& h) const; |
---|
53 | void measure(int& w, int& h) const {_measure(w,h);} |
---|
54 | |
---|
55 | virtual void _draw(const Rectangle&) const = 0; |
---|
56 | void draw(const Rectangle& r) const {_draw(r);} |
---|
57 | void draw(const Rectangle& r, const Style*, Flags) const; |
---|
58 | |
---|
59 | uchar* readimage(uchar*, const Rectangle&) const; |
---|
60 | uchar* readimage(uchar*, const Rectangle&, int delta) const; |
---|
61 | uchar* readimage(uchar*, const Rectangle&, int delta, int linedelta) const; |
---|
62 | |
---|
63 | // Hints for widgets: |
---|
64 | virtual void inset(Rectangle& r) const; |
---|
65 | virtual bool fills_rectangle() const; |
---|
66 | virtual bool is_frame() const; |
---|
67 | |
---|
68 | // hash table lookup: |
---|
69 | static const Symbol* find(const char* name); |
---|
70 | static const Symbol* find(const char* start, const char* end); |
---|
71 | static const Symbol* iterate(int& index); |
---|
72 | static void text(const char* s) {text_=s;} |
---|
73 | static const char* text() {return text_;} |
---|
74 | |
---|
75 | // virtual ~Symbol() {} // not done as it slows program exit |
---|
76 | }; |
---|
77 | |
---|
78 | // Back-compatability constructor: |
---|
79 | FL_API void add_symbol(const char* name, void (*drawit)(Color), int scalable); |
---|
80 | |
---|
81 | } |
---|
82 | |
---|
83 | #endif |
---|