summaryrefslogtreecommitdiffstats
path: root/kedit/kedit.h
blob: 93a0d02178711349e2a4c63368dfcb86b98dbc1b (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*

    $Id$

    Copyright (C) 1997 Bernd Johannes Wuebben
                       wuebben@math.cornell.edu

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

    */

#ifndef _KEDIT_H_
#define _KEDIT_H_

#include <tqtextcodec.h>
#include <tqptrdict.h>

#include "version.h"

#include <tdemainwindow.h>

class KEdit;
class KSpell;
class KSpellConfig;
class TQTimer;
class TDEAction;
class TDERecentFilesAction;

namespace TDEIO { class Job; }

// StatusBar field IDs
#define ID_LINE_COLUMN 1
#define ID_INS_OVR 2
#define ID_GENERAL 3

class TopLevel : public TDEMainWindow
{
    TQ_OBJECT
  

public:
    enum { KEDIT_OK 		= 0,
	   KEDIT_OS_ERROR 	= 1,
	   KEDIT_USER_CANCEL 	= 2 ,
	   KEDIT_RETRY 		= 3,
	   KEDIT_NOPERMISSIONS 	= 4};

    enum { OPEN_READWRITE 	= 1,
	   OPEN_READONLY 	= 2,
	   OPEN_INSERT 		= 4,
	   OPEN_NEW             = 8 };

    TopLevel( TQWidget *parent=0, const char *name=0 );
    ~TopLevel();

    /**
     * Reads a file into the edit widget.
     *
     * @return KEDIT_OK on success
     */
    int openFile( const TQString& _filename, int _mode, const TQString &encoding, bool _undoAction = false );

    /**
     * Saves the edit widget to a file.
     *
     * @return KEDIT_OK on success
     */
    int saveFile( const TQString& _filename, bool backup, const TQString &encoding);

    /**
     * Works like openFile but is able to open remote files
     */
    void openURL( const KURL& _url, int _mode );

    /**
     * Saves the current text to the URL '_url'.
     *
     * @return KEDIT::KEDIT_OK on success
     */

    int saveURL( const KURL& _url );

    /**
     * Only show the window when the following load action is successful.
     **/
    void setNewWindow() { newWindow = true; }

    /**
     * set url
     */
    void setUrl(const KURL &url) { m_url = url; }

    /// List of all windows
    static TQPtrList<TopLevel> *windowList;
    //TQPopupMenu *right_mouse_button;

    bool queryExit( void );
    bool queryClose( void );

protected:
    void setSensitivity();
    void setupEditWidget();
    void setupStatusBar();
    void setupActions();
    void initSpellConfig();

private:
    KSpellConfig *tdespellconfigOptions;
    
public:  // Should not be!
    KEdit *eframe;
private:
    KURL m_url;
    TQString m_caption;

    bool newWindow;
    int statusID, toolID, indentID;
    TQTimer *statusbar_timer;
    TDERecentFilesAction *recent;
    TDEAction *cutAction;
    TDEAction *copyAction;
    TDEAction *undoAction;
    TDEAction *redoAction;

    int open_mode;

    TDEConfig *config;

    KSpell *tdespell; // Current spell checking object

    /*
     * The source, the destination of the copy, and the open mode
     * for each job being run (job ptr is the dict key).
     */
    TQPtrDict <TQString> m_sNet;
    TQPtrDict <TQString> m_sLocal;
    TQPtrDict <int> m_openMode;

    // Session management
    void saveProperties(TDEConfig*);
    void readProperties(TDEConfig*);

public slots:
    void openRecent(const KURL&);
    void gotoLine();
    void mail();
    void setGeneralStatusField(const TQString &string);
    void undo();
    void redo();
    void copy();
    void paste();
    void cut();
    void insertDate();
    void print();
    void select_all();
    void clean_space();
    void timer_slot();
    void file_open();
    void file_new();
    void file_insert();
    void setFileCaption();
    void statusbar_slot();
    void file_close();
    void file_save();
    void file_save_as();
    void helpselected();
    void search();
    void replace();
    void search_again();
    void toggle_overwrite();

    void spellcheck();
    void spell_started ( KSpell *);
    void spell_progress (unsigned int percent);
    void spell_done(const TQString&);
    void spell_finished();

    void urlDrop_slot(TQDropEvent* e);

    void set_colors();

protected:
    /// Drag and Drop
    void dragEnterEvent(TQDragEnterEvent* e);
    void dropEvent(TQDropEvent* e);

private slots:
    void updateSettings();
    void readSettings();
    void showSettings();
    void slotSelectionChanged();
    TQString replaceISpell(TQString msg, int client);
};

class SettingsDialog: public TDEConfigDialog {
TQ_OBJECT
  

public:
  SettingsDialog(TQWidget *parent, const char *name,TDEConfigSkeleton *config, KSpellConfig *_spellConfig);
  
protected slots:
  void updateSettings();
  void updateWidgets();
  void updateWidgetsDefault();
  void slotSpellConfigChanged();
  
protected:
  bool hasChanged();
  bool isDefault();

private:
  KSpellConfig *spellConfig;  
  bool spellConfigChanged;
};


#endif