1 /**
2  *  Yudit Unicode Editor Source File
3  *
4  *  GNU Copyright (C) 1997-2006  Gaspar Sinai <gaspar@yudit.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License, version 2,
8  *  dated June 1991. See file COPYYING for details.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef SFreeHand_h
21 #define SFreeHand_h
22 
23 #include "swidget/SDrawing.h"
24 
25 #include "swidget/SButton.h"
26 #include "swidget/SLabel.h"
27 #include "swidget/SListBox.h"
28 #include "stoolkit/SString.h"
29 #include "stoolkit/SHWConverter.h"
30 
31 class SFreeHandListener
32 {
33 public:
34   SFreeHandListener(void);
35   virtual ~SFreeHandListener();
36   virtual void freeHandTextChanged (void* source, const SString& lookup)=0;
37 };
38 
39 class SFreeHand : public SPanel, public SListListener,
40   public SButtonListener, public SDrawingListener
41 {
42 public:
43   SFreeHand (void);
44   virtual ~SFreeHand ();
45   void  setFreeHandListener (SFreeHandListener* listener);
46 
47   virtual void setFont (const SString& font, double fontSize);
48   virtual void setFontSize (double fontSize);
49   virtual void setButtonFont (const SString& font, double fontSize);
50 
51   virtual void setBackground (const SColor& bg);
52   virtual void setDrawingBackground (const SColor& bg);
53   virtual void setSliderBackground (const SColor& bg);
54 
55   void setForeground (const SColor&  lrfg, const SColor& rlfg);
56   void setLabelForeground (const SColor& lrfg, const SColor& rlfg);
57   void setDrawingForeground (const SColor& fg, const SColor& fgrecent);
58 
59 
60   virtual void redraw (SCanvas *canvas, int x, int y,
61      unsigned int width, unsigned int height);
62 
63   virtual void buttonPressedAccel (void* source, const SAccelerator* acc);
64   virtual void itemSelected (void* source, const SAccelerator* acc);
65   virtual void resize (const SDimension& _size);
66   virtual void clicked (void* source, int button);
67   virtual void strokeChanged(void* src, unsigned int newsize);
68   const SString&    getLookupText();
69 
70   void              setConverter (const SString& name);
71   const SString&    getConverter () const;
72   bool              isOK () const;
73 
74 protected:
75   void convertOne();
76   void initConverters();
77   bool              needConversion;
78   SHWConverter      converter;
79   void              recalc ();
80   SString	    lookupText;
81   SStringVector	    allConverters;
82   SFreeHandListener   *listener;
83   bool              isDirected;
84 
85   SButton*          lookupButton;
86   SButton*          clearButton;
87   SButton*          directedButton;
88   SLabel*           strokesLabel;
89   SLabel*           strokesCount;
90   SLabel*           titleLabel;
91   SListBox*         candidates;
92   SListBox*         converters;
93   SDrawing*         drawing;
94 };
95 
96 #endif /* SFreeHand_h */
97