knotes

knoteedit.h
1 /*******************************************************************
2  KNotes -- Notes for the KDE project
3 
4  Copyright (c) 1997-2004, The KNotes Developers
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *******************************************************************/
20 
21 #ifndef KNOTEEDIT_H
22 #define KNOTEEDIT_H
23 
24 #include <tqwidget.h>
25 
26 #include <ktextedit.h>
27 class KNote;
28 class TQFont;
29 class TQColor;
30 class TQPushButton;
31 class TDEAction;
32 class TDEActionCollection;
33 class TDEToggleAction;
34 class TDEFontAction;
35 class TDEFontSizeAction;
36 
37 
38 class KNoteEdit : public KTextEdit
39 {
40  TQ_OBJECT
41 
42 public:
43  KNoteEdit( TDEActionCollection *actions, TQWidget *parent=0, const char *name=0 );
44  ~KNoteEdit();
45  void setNote( KNote *_note ) {
46  m_note = _note;
47  }
48  void setText( const TQString& text );
49  void setTextFont( const TQFont& font );
50  void setTextColor( const TQColor& color );
51  void setTabStop( int tabs );
52  void setAutoIndentMode( bool newmode );
53 
54 public slots:
55  virtual void setTextFormat( TextFormat f );
56 
57  void textStrikeOut( bool );
58 
59  void textColor();
60 
61  void textAlignLeft();
62  void textAlignCenter();
63  void textAlignRight();
64  void textAlignBlock();
65 
66  void textList();
67 
68  void textSuperScript();
69  void textSubScript();
70 
71  //void textIncreaseIndent();
72  //void textDecreaseIndent();
73  void slotCutEnabled( bool );
74 
75 protected:
76  virtual void contentsDragEnterEvent( TQDragEnterEvent *e );
77  virtual void contentsDropEvent( TQDropEvent *e );
78  virtual TQPopupMenu *createPopupMenu( const TQPoint &pos );
79 
80 private slots:
81  void slotReturnPressed();
82 
83  void fontChanged( const TQFont &f );
84  void colorChanged( const TQColor &c );
85  void alignmentChanged( int a );
86  void verticalAlignmentChanged( VerticalAlignment a );
87  void slotAllowTab();
88 
89  void setEnabledRedo( bool b );
90  void setEnabledUndo( bool b );
91 
92 private:
93  void autoIndent();
94 
95  virtual bool linksEnabled() const { return true; }
96  virtual void emitLinkClicked( const TQString &s );
97 
98  void enableRichTextActions();
99  void disableRichTextActions();
100 
101 private:
102  TDEAction *m_cut;
103  TDEAction *m_copy;
104  TDEAction *m_paste;
105 
106  TDEToggleAction *m_textBold;
107  TDEToggleAction *m_textItalic;
108  TDEToggleAction *m_textUnderline;
109  TDEToggleAction *m_textStrikeOut;
110 
111  TDEToggleAction *m_textAlignLeft;
112  TDEToggleAction *m_textAlignCenter;
113  TDEToggleAction *m_textAlignRight;
114  TDEToggleAction *m_textAlignBlock;
115 
116  TDEToggleAction *m_textList;
117  TDEToggleAction *m_textSuper;
118  TDEToggleAction *m_textSub;
119 
120  //TDEAction *m_textIncreaseIndent;
121  //TDEAction *m_textDecreaseIndent;
122 
123  TDEAction *m_textColor;
124  TDEFontAction *m_textFont;
125  TDEFontSizeAction *m_textSize;
126  TDEAction* undo;
127  TDEAction* redo;
128  bool m_autoIndentMode;
129  KNote *m_note;
130 };
131 
132 #endif