summaryrefslogtreecommitdiffstats
path: root/kbabel/kbabel/hidingmsgedit.h
blob: 96ded8a63dc32d1a949f4f3e3f1f6cf43d0dd800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/***************************************************************************
                          hidingmsgedit.h  -  description
                             -------------------
    begin                : So nov 2 2002
    copyright            : (C) 2002 by Stanislav Visnovsky
    email                : visnovsky@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *

  In addition, as a special exception, the copyright holders give
  permission to link the code of this program with any edition of
  the TQt library by Trolltech AS, Norway (or with modified versions
  of TQt that use the same license as TQt), and distribute linked
  combinations including the two.  You must obey the GNU General
  Public License in all respects for all of the code used other than
  TQt. If you modify this file, you may extend this exception to
  your version of the file, but you are not obligated to do so.  If
  you do not wish to do so, delete this exception statement from
  your version.

 *                                                                         *
 ***************************************************************************/

#ifndef HIDINGMSGEDIT_H
#define HIDINGMSGEDIT_H

#include <tqwidgetstack.h>
#include <tqguardedptr.h>
#include <tqptrlist.h>

#include "mymultilineedit.h"

class KSpell;
class TQTabWidget;
class TQPopupMenu;

namespace KBabel
{
    class EditCommand;
}

/**
  *@author Stanislav Visnovsky <visnovsky@kde.org>
  */

class HidingMsgEdit : public TQWidgetStack  {
   TQ_OBJECT
  
public: 
  HidingMsgEdit(uint numberOfPlurals, TQWidget* eventFilter=0, KSpell* spell=0, TQWidget *parent=0, const char *name=0);
  ~HidingMsgEdit();
  
  void setNumberOfPlurals(uint numberOfPlurals);
  
  // return index number for a currently shown plural form (0=singular or no plurals)
  uint currentForm();

  // MsgMultiLineEdit interface
  bool isOverwriteMode() const { return _currentEdit->isOverwriteMode(); }
  bool isModified();
  bool hasSelectedText() const { return _currentEdit->hasSelectedText(); }
  TQString selectedText () const { return _currentEdit->selectedText(); }
  void processCommand(KBabel::EditCommand* cmd, bool undo=false);
  void offset2Pos(int offset, int &row, int &col) const
	{ return _currentEdit->offset2Pos(offset, row, col ); }
  void getCursorPosition(int *para, int *index) const
	{ _currentEdit->getCursorPosition(para,index); }
  int currentIndex() const
	{ return _currentEdit->currentIndex(); }
  int beginOfLastMarkedText() const
    { return _currentEdit->beginOfLastMarkedText(); }
  virtual void setFont ( const TQFont & );
  void setCurrentColor(const MsgMultiLineEdit::TextColor color);
  bool spacePoints() const { return _currentEdit->spacePoints(); }
  void setSpacePoints(bool on);
  bool quotes() const { return _currentEdit->quotes(); }
  void setQuotes(bool on);
  void setBgColor( const TQColor& color);
  bool highlightBg() const { return _currentEdit->highlightBg(); }
  bool highlightSyntax() const { return _currentEdit->highlightSyntax(); }
  void setHighlightColors(const TQColor& quoteColor, const TQColor& unquoteColor
        , const TQColor& cformatColor, const TQColor& accelColor, const TQColor& tagColor); 
  int beginOfMarkedText() { return _currentEdit->beginOfMarkedText(); }
  virtual void insertAt ( const TQString & s, int line, int col, bool mark = false )
        { _currentEdit->insertAt( s, line, col, mark ); }

  void setDiffMode(bool on);
  void setDiffDisplayMode(bool underlineAdded, bool strikeOutDeleted);
  void setDiffColors(const TQColor& addColor, const TQColor& delColor);     
  TQString text(int para) { return _currentEdit->text(para); }
 
  void setSpellChecker(KSpell* spell);
 
  void selectTag(int start, int length) { _currentEdit->selectTag(start,length); }

  // reiplemented to return correct value
  bool hasFocus ();
public slots: // Public slots
  void setText(TQStringList texts, TQString msgctxt = TQString());
  void showSingle();
  void showMultiple();
  void showPlurals( bool on );
  void showForm(int form);
  virtual void setFocus() { _currentEdit->setFocus(); }
  void forceUpdate() { _currentEdit->forceUpdate(); }
  
  // MsgMultiLineEdit interface
  virtual void setReadOnly( bool b );
  virtual void setOverwriteMode( bool b );
  virtual void setModified( bool b );
  void setCleverEditing( bool on );
  void setHighlightBg( bool on );
  void setHighlightSyntax( bool on );
  virtual void clear() { _currentEdit->clear(); }
  virtual void cut() { _currentEdit->cut(); }
  virtual void copy() { _currentEdit->copy(); }
  virtual void paste() { _currentEdit->paste(); }
  virtual void setSelection( int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum = 0 )
	{ _currentEdit->setSelection( paraFrom, indexFrom, paraTo, indexTo, selNum) ; }
  virtual void selectAll(bool select=true) { _currentEdit->selectAll(select); }
  virtual void setCursorPosition ( int para, int index )
	{ _currentEdit->setCursorPosition(para,index); }
  virtual void setContextMenu( TQPopupMenu *menu );

signals:
  void signalUndoCmd(KBabel::EditCommand*);
  void textChanged();
  void textChanged(const TQString&);
  void cursorPositionChanged ( int para, int pos );
  void currentFormChanged ( uint form );

private slots:
  
  void emitTextChanged();
  
  // invoked if TabWidget changes the shown widget
  void newCurrentMultiple( TQWidget * );  
  // invoked by inner cursorPositionChanged() to transform line/col for wrapping
  void emitCursorPositionChanged( int para, int pos );

private: // Private attributes
  /** Used for editting non-plural messages */
  MsgMultiLineEdit* _singleEdit;
  /** Used for editting plural forms */
  TQTabWidget* _multipleEdit;
  TQWidget* _eventFilter;
  
  MsgMultiLineEdit* _currentEdit;
  TQPtrList<MsgMultiLineEdit> _allEdits;
  
  uint _numberOfPlurals;
  
  TQGuardedPtr<KSpell> _spell;
};

#endif