root/trunk/qt4-gui/src/widgets/mledit.h

Revision 6239, 2.6 kB (checked in by eugene, 6 months ago)

Introduced Fixed font setting and made it to be used in network log and file editors.
Default fixed font is constructed by taking global qApp->font() and setting Monospace family on it.

  • Property svn:eol-style set to native
Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of Licq, an instant messaging client for UNIX.
4 * Copyright (C) 1999-2006 Licq developers
5 *
6 * Licq is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Licq 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 Licq; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20
21#ifndef MLEDIT_H
22#define MLEDIT_H
23
24#include "config.h"
25
26#ifdef USE_KDE
27# include <KDE/KTextEdit>
28# define MLEDIT_BASE KTextEdit
29#else
30# include <QTextEdit>
31# define MLEDIT_BASE QTextEdit
32#endif
33
34
35namespace LicqQtGui
36{
37
38class MLEdit : public MLEDIT_BASE
39{
40  Q_OBJECT
41
42public:
43  MLEdit(bool wordWrap, QWidget* parent = 0, bool useFixedFont = false, const char* name = 0);
44  virtual ~MLEdit();
45
46  void appendNoNewLine(const QString& s);
47  void GotoEnd();
48
49  void setBackground(const QColor& color);
50  void setForeground(const QColor& color);
51
52#ifndef USE_KDE
53  void setCheckSpellingEnabled(bool /* check */) {}
54  bool checkSpellingEnabled() const { return false; }
55#endif
56
57  /**
58   * Caclulate height for widget to fit a specified number of lines with
59   * current font
60   *
61   * @param lines Number of text lines to calculate for
62   * @return Widget height in pixels
63   */
64  int heightForLines(int lines) const;
65
66  /**
67   * Set size hint as number of lines of text
68   *
69   * @param lines Lines of text that should be visible
70   */
71  void setSizeHintLines(int lines);
72
73  /**
74   * Get recommended widget size
75   *
76   * @return Recommended size
77   */
78  QSize sizeHint() const;
79
80signals:
81  void ctrlEnterPressed();
82  void clicked();
83
84private:
85  bool myUseFixedFont;
86  bool myFixSetTextNewlines;
87  bool myLastKeyWasReturn;
88  int myFontHeight;
89  int myLinesHint;
90
91  virtual void keyPressEvent(QKeyEvent* event);
92  virtual void mousePressEvent(QMouseEvent* event);
93#ifndef USE_KDE
94  virtual void contextMenuEvent(QContextMenuEvent* event);
95#endif
96
97#if 0
98//TODO: This may or may not be needed for KTextEdit in KDE 4
99public slots:
100  void setText(const QString& text);
101  virtual void setText(const QString& text, const QString& context);
102#endif
103
104private slots:
105  void updateFont();
106  void toggleAllowTab();
107};
108
109} // namespace LicqQtGui
110
111#endif
Note: See TracBrowser for help on using the browser.