⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qrichtext_p.h

📁 linux下聊天室的稳定版本
💻 H
📖 第 1 页 / 共 4 页
字号:
/****************************************************************************** $Id: qt/qrichtext_p.h   3.3.6   edited Aug 31 2005 $**** Definition of internal rich text classes**** Created : 990124**** Copyright (C) 1999-2005 Trolltech AS.  All rights reserved.**** This file is part of the kernel module of the Qt GUI Toolkit.**** This file may be distributed under the terms of the Q Public License** as defined by Trolltech AS of Norway and appearing in the file** LICENSE.QPL included in the packaging of this file.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition** licenses may use this file in accordance with the Qt Commercial License** Agreement provided with the Software.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Qt Commercial License Agreements.** See http://www.trolltech.com/qpl/ for QPL licensing information.** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#ifndef QRICHTEXT_P_H#define QRICHTEXT_P_H////  W A R N I N G//  -------------//// This file is not part of the Qt API.  It exists for the convenience// of a number of Qt sources files.  This header file may change from// version to version without notice, or even be removed.//// We mean it.////#ifndef QT_H#include "qstring.h"#include "qptrlist.h"#include "qrect.h"#include "qfontmetrics.h"#include "qintdict.h"#include "qmap.h"#include "qstringlist.h"#include "qfont.h"#include "qcolor.h"#include "qsize.h"#include "qvaluelist.h"#include "qvaluestack.h"#include "qobject.h"#include "qdict.h"#include "qpixmap.h"#include "qstylesheet.h"#include "qptrvector.h"#include "qpainter.h"#include "qlayout.h"#include "qobject.h"#include "qapplication.h"#endif // QT_H#ifndef QT_NO_RICHTEXTclass QTextDocument;class QTextString;class QTextPreProcessor;class QTextFormat;class QTextCursor;class QTextParagraph;class QTextFormatter;class QTextIndent;class QTextFormatCollection;class QStyleSheetItem;#ifndef QT_NO_TEXTCUSTOMITEMclass QTextCustomItem;#endifclass QTextFlow;struct QBidiContext;// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++class Q_EXPORT QTextStringChar{    friend class QTextString;public:    // this is never called, initialize variables in QTextString::insert()!!!    QTextStringChar() : nobreak(FALSE), lineStart( 0 ), type( Regular ) {d.format=0;}    ~QTextStringChar();    struct CustomData    {	QTextFormat *format;#ifndef QT_NO_TEXTCUSTOMITEM	QTextCustomItem *custom;#endif	QString anchorName;	QString anchorHref;    };    enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 };    QChar c;    // this is the same struct as in qtextengine_p.h. Don't change!    uchar softBreak      :1;     // Potential linebreak point    uchar whiteSpace     :1;     // A unicode whitespace character, except NBSP, ZWNBSP    uchar charStop       :1;     // Valid cursor position (for left/right arrow)    uchar wordStop       :1;     // Valid cursor position (for ctrl + left/right arrow)    uchar nobreak        :1;    uchar lineStart : 1;    uchar /*Type*/ type : 2;    uchar bidiLevel       :7;    uchar rightToLeft : 1;    int x;    union {	QTextFormat* format;	CustomData* custom;    } d;    int height() const;    int ascent() const;    int descent() const;    bool isCustom() const { return (type & Custom) != 0; }    QTextFormat *format() const;#ifndef QT_NO_TEXTCUSTOMITEM    QTextCustomItem *customItem() const;#endif    void setFormat( QTextFormat *f );#ifndef QT_NO_TEXTCUSTOMITEM    void setCustomItem( QTextCustomItem *i );#endif#ifndef QT_NO_TEXTCUSTOMITEM    void loseCustomItem();#endif    bool isAnchor() const { return ( type & Anchor) != 0; }    bool isLink() const { return isAnchor() && !!d.custom->anchorHref; }    QString anchorName() const;    QString anchorHref() const;    void setAnchor( const QString& name, const QString& href );private:    QTextStringChar &operator=( const QTextStringChar & ) {	//abort();	return *this;    }    QTextStringChar( const QTextStringChar & ) {    }    friend class QTextParagraph;};#if defined(Q_TEMPLATEDLL)// MOC_SKIP_BEGINQ_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>;// MOC_SKIP_END#endifclass Q_EXPORT QTextString{public:    QTextString();    QTextString( const QTextString &s );    virtual ~QTextString();    static QString toString( const QMemArray<QTextStringChar> &data );    QString toString() const;    inline QTextStringChar &at( int i ) const { return data[ i ]; }    inline int length() const { return data.size(); }    int width( int idx ) const;    void insert( int index, const QString &s, QTextFormat *f );    void insert( int index, const QChar *unicode, int len, QTextFormat *f );    void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE );    void truncate( int index );    void remove( int index, int len );    void clear();    void setFormat( int index, QTextFormat *f, bool useCollection );    void setBidi( bool b ) { bidi = b; }    bool isBidi() const;    bool isRightToLeft() const;    QChar::Direction direction() const;    void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; }    QMemArray<QTextStringChar> rawData() const { return data.copy(); }    void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); }    void operator+=( const QString &s ) { insert( length(), s, 0 ); }    void prepend( const QString &s ) { insert( 0, s, 0 ); }    int appendParagraphs( QTextParagraph *start, QTextParagraph *end );    // return next and previous valid cursor positions.    bool validCursorPosition( int idx );    int nextCursorPosition( int idx );    int previousCursorPosition( int idx );private:    void checkBidi() const;    QMemArray<QTextStringChar> data;    QString stringCache;    uint bidiDirty : 1;    uint bidi : 1; // true when the paragraph has right to left characters    uint rightToLeft : 1;    uint dir : 5;};inline bool QTextString::isBidi() const{    if ( bidiDirty )	checkBidi();    return bidi;}inline bool QTextString::isRightToLeft() const{    if ( bidiDirty )	checkBidi();    return rightToLeft;}inline QString QTextString::toString() const{    if(bidiDirty)        checkBidi();    return stringCache;}inline QChar::Direction QTextString::direction() const{    return (QChar::Direction) dir;}inline int QTextString::nextCursorPosition( int next ){    if ( bidiDirty )	checkBidi();    const QTextStringChar *c = data.data();    int len = length();    if ( next < len - 1 ) {	next++;	while ( next < len - 1 && !c[next].charStop )	    next++;    }    return next;}inline int QTextString::previousCursorPosition( int prev ){    if ( bidiDirty )	checkBidi();    const QTextStringChar *c = data.data();    if ( prev ) {	prev--;	while ( prev && !c[prev].charStop )	    prev--;    }    return prev;}inline bool QTextString::validCursorPosition( int idx ){    if ( bidiDirty )	checkBidi();    return (at( idx ).charStop);}// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#if defined(Q_TEMPLATEDLL)// MOC_SKIP_BEGINQ_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<int>;Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<QTextParagraph*>;Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<bool>;// MOC_SKIP_END#endifclass Q_EXPORT QTextCursor{public:    QTextCursor( QTextDocument *d = 0 );    QTextCursor( const QTextCursor &c );    QTextCursor &operator=( const QTextCursor &c );    virtual ~QTextCursor() {}    bool operator==( const QTextCursor &c ) const;    bool operator!=( const QTextCursor &c ) const { return !(*this == c); }    inline QTextParagraph *paragraph() const { return para; }    QTextDocument *document() const;    int index() const;    void gotoPosition( QTextParagraph* p, int index = 0);    void setIndex( int index ) { gotoPosition(paragraph(), index ); }    void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); }    void gotoLeft();    void gotoRight();    void gotoNextLetter();    void gotoPreviousLetter();    void gotoUp();    void gotoDown();    void gotoLineEnd();    void gotoLineStart();    void gotoHome();    void gotoEnd();    void gotoPageUp( int visibleHeight );    void gotoPageDown( int visibleHeight );    void gotoNextWord( bool onlySpace = FALSE );    void gotoPreviousWord( bool onlySpace = FALSE );    void gotoWordLeft();    void gotoWordRight();    void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 );    void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE );    bool remove();    bool removePreviousChar();    void indent();    bool atParagStart();    bool atParagEnd();    int x() const; // x in current paragraph    int y() const; // y in current paragraph    int globalX() const;    int globalY() const;    QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); }    int offsetX() const { return ox; } // inner document  offset    int offsetY() const { return oy; } // inner document offset    int totalOffsetX() const; // total document offset    int totalOffsetY() const; // total document offset    bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); }    bool place( const QPoint &pos, QTextParagraph *s, bool link ) { return place( pos, s, link, TRUE, TRUE ); }    bool place( const QPoint &pos, QTextParagraph *s, bool link, bool loosePlacing, bool matchBetweenCharacters );    void restoreState();    int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast    void oneUp() { if ( !indices.isEmpty() ) pop(); }    void setValid( bool b ) { valid = b; }    bool isValid() const { return valid; }    void fixCursorPosition();private:    enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down };    void push();    void pop();    bool processNesting( Operation op );    void invalidateNested();    void gotoIntoNested( const QPoint &globalPos );    QTextParagraph *para;    int idx, tmpX;    int ox, oy;    QValueStack<int> indices;    QValueStack<QTextParagraph*> paras;    QValueStack<int> xOffsets;    QValueStack<int> yOffsets;    uint valid : 1;};// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++class Q_EXPORT QTextCommand{public:    enum Commands { Invalid, Insert, Delete, Format, Style };    QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {}    virtual ~QTextCommand();    virtual Commands type() const;    virtual QTextCursor *execute( QTextCursor *c ) = 0;    virtual QTextCursor *unexecute( QTextCursor *c ) = 0;protected:    QTextDocument *doc;    QTextCursor cursor;};#if defined(Q_TEMPLATEDLL)// MOC_SKIP_BEGINQ_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCommand>;// MOC_SKIP_END#endifclass Q_EXPORT QTextCommandHistory{public:    QTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); }    virtual ~QTextCommandHistory();    void clear() { history.clear(); current = -1; }    void addCommand( QTextCommand *cmd );    QTextCursor *undo( QTextCursor *c );    QTextCursor *redo( QTextCursor *c );    bool isUndoAvailable();    bool isRedoAvailable();    void setUndoDepth( int d ) { steps = d; }    int undoDepth() const { return steps; }    int historySize() const { return history.count(); }    int currentPosition() const { return current; }private:    QPtrList<QTextCommand> history;    int current, steps;};inline QTextCommandHistory::~QTextCommandHistory(){    clear();}// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#ifndef QT_NO_TEXTCUSTOMITEMclass Q_EXPORT QTextCustomItem{public:    QTextCustomItem( QTextDocument *p )	:  xpos(0), ypos(-1), width(-1), height(0), parent( p )    {}    virtual ~QTextCustomItem();    virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0;    virtual void adjustToPainter( QPainter* );    enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight };    virtual Placement placement() const;    bool placeInline() { return placement() == PlaceInline; }    virtual bool ownLine() const;    virtual void resize( int nwidth );    virtual void invalidate();    virtual int ascent() const { return height; }    virtual bool isNested() const;    virtual int minimumWidth() const;    virtual QString richText() const;    int xpos; // used for floating items    int ypos; // used for floating items    int width;    int height;    QRect geometry() const { return QRect( xpos, ypos, width, height ); }    virtual bool enter( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE );    virtual bool enterAt( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, const QPoint & );    virtual bool next( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );    virtual bool prev( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );    virtual bool down( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );    virtual bool up( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );    virtual void setParagraph( QTextParagraph *p ) { parag = p; }    QTextParagraph *paragraph() const { return parag; }    QTextDocument *parent;    QTextParagraph *parag;    virtual void pageBreak( int  y, QTextFlow* flow );};#endif#if defined(Q_TEMPLATEDLL)// MOC_SKIP_BEGIN//Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QString, QString>;// MOC_SKIP_END#endif#ifndef QT_NO_TEXTCUSTOMITEMclass Q_EXPORT QTextImage : public QTextCustomItem{public:    QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,		QMimeSourceFactory &factory );    virtual ~QTextImage();    Placement placement() const { return place; }    void adjustToPainter( QPainter* );    int minimumWidth() const { return width; }    QString richText() const;    void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );private:    QRegion* reg;    QPixmap pm;    Placement place;    int tmpwidth, tmpheight;    QMap<QString, QString> attributes;    QString imgId;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -