kateviewinternal.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _KATE_VIEW_INTERNAL_
00025 #define _KATE_VIEW_INTERNAL_
00026
00027 #include "katecursor.h"
00028 #include "katesupercursor.h"
00029 #include "katelinerange.h"
00030 #include "katetextline.h"
00031
00032 #include <qscrollbar.h>
00033 #include <qpoint.h>
00034 #include <qtimer.h>
00035 #include <qintdict.h>
00036
00037 class KateView;
00038 class KateDocument;
00039 class KateIconBorder;
00040
00041 class QHBoxLayout;
00042 class QVBoxLayout;
00043
00044 enum Bias
00045 {
00046 left = -1,
00047 none = 0,
00048 right = 1
00049 };
00050
00058 class KateScrollBar : public QScrollBar
00059 {
00060 Q_OBJECT
00061
00062 public:
00063 KateScrollBar(Orientation orientation, class KateViewInternal *parent, const char* name = 0L);
00064
00065 inline bool showMarks() { return m_showMarks; };
00066 inline void setShowMarks(bool b) { m_showMarks = b; update(); };
00067
00068 signals:
00069 void sliderMMBMoved(int value);
00070
00071 protected:
00072 virtual void mousePressEvent(QMouseEvent* e);
00073 virtual void mouseReleaseEvent(QMouseEvent* e);
00074 virtual void mouseMoveEvent (QMouseEvent* e);
00075 virtual void paintEvent(QPaintEvent *);
00076 virtual void resizeEvent(QResizeEvent *);
00077 virtual void styleChange(QStyle &oldStyle);
00078 virtual void valueChange();
00079 virtual void rangeChange();
00080
00081 protected slots:
00082 void sliderMaybeMoved(int value);
00083 void marksChanged();
00084
00085 private:
00086 void redrawMarks();
00087 void recomputeMarksPositions(bool forceFullUpdate = false);
00088 void watchScrollBarSize();
00089
00090 bool m_middleMouseDown;
00091
00092 KateView *m_view;
00093 KateDocument *m_doc;
00094 class KateViewInternal *m_viewInternal;
00095
00096 int m_topMargin;
00097 int m_bottomMargin;
00098 uint m_savVisibleLines;
00099
00100 QIntDict<QColor> m_lines;
00101
00102 bool m_showMarks;
00103 };
00104
00105 class KateViewInternal : public QWidget
00106 {
00107 Q_OBJECT
00108
00109 friend class KateView;
00110 friend class KateIconBorder;
00111 friend class KateScrollBar;
00112 friend class CalculatingCursor;
00113 friend class BoundedCursor;
00114 friend class WrappingCursor;
00115
00116 public:
00117 KateViewInternal ( KateView *view, KateDocument *doc );
00118 ~KateViewInternal ();
00119
00120
00121 public:
00122 void editStart ();
00123 void editEnd (int editTagLineStart, int editTagLineEnd, bool tagFrom);
00124
00125 void editSetCursor (const KateTextCursor &cursor);
00126
00127 private:
00128 uint editSessionNumber;
00129 bool editIsRunning;
00130 KateTextCursor editOldCursor;
00131
00132
00133
00134 public:
00135 bool tagLine (const KateTextCursor& virtualCursor);
00136
00137 bool tagLines (int start, int end, bool realLines = false);
00138 bool tagLines (KateTextCursor start, KateTextCursor end, bool realCursors = false);
00139
00140 void tagAll ();
00141
00142 void clear ();
00143
00144
00145 private:
00146 void updateView (bool changed = false, int viewLinesScrolled = 0);
00147 void makeVisible (const KateTextCursor& c, uint endCol, bool force = false, bool center = false, bool calledExternally = false);
00148
00149 public:
00150 inline const KateTextCursor& startPos() const { return m_startPos; }
00151 inline uint startLine () const { return m_startPos.line(); }
00152 inline uint startX () const { return m_startX; }
00153
00154 KateTextCursor endPos () const;
00155 uint endLine () const;
00156
00157 KateLineRange yToKateLineRange(uint y) const;
00158
00159 void prepareForDynWrapChange();
00160 void dynWrapChanged();
00161
00162 public slots:
00163 void slotIncFontSizes();
00164 void slotDecFontSizes();
00165
00166 private slots:
00167 void scrollLines(int line);
00168 void scrollViewLines(int offset);
00169 void scrollNextPage();
00170 void scrollPrevPage();
00171 void scrollPrevLine();
00172 void scrollNextLine();
00173 void scrollColumns (int x);
00174 void docSelectionChanged ();
00175
00176 public:
00177 void doReturn();
00178 void doDelete();
00179 void doBackspace();
00180 void doPaste();
00181 void doTranspose();
00182 void doDeleteWordLeft();
00183 void doDeleteWordRight();
00184
00185 void cursorLeft(bool sel=false);
00186 void cursorRight(bool sel=false);
00187 void wordLeft(bool sel=false);
00188 void wordRight(bool sel=false);
00189 void home(bool sel=false);
00190 void end(bool sel=false);
00191 void cursorUp(bool sel=false);
00192 void cursorDown(bool sel=false);
00193 void cursorToMatchingBracket(bool sel=false);
00194 void scrollUp();
00195 void scrollDown();
00196 void topOfView(bool sel=false);
00197 void bottomOfView(bool sel=false);
00198 void pageUp(bool sel=false);
00199 void pageDown(bool sel=false);
00200 void top(bool sel=false);
00201 void bottom(bool sel=false);
00202 void top_home(bool sel=false);
00203 void bottom_end(bool sel=false);
00204
00205 inline const KateTextCursor& getCursor() { return cursor; }
00206 QPoint cursorCoordinates();
00207
00208 void paintText (int x, int y, int width, int height, bool paintOnlyDirty = false);
00209
00210
00211 protected:
00212 void paintEvent(QPaintEvent *e);
00213 bool eventFilter( QObject *obj, QEvent *e );
00214 void keyPressEvent( QKeyEvent* );
00215 void keyReleaseEvent( QKeyEvent* );
00216 void resizeEvent( QResizeEvent* );
00217 void mousePressEvent( QMouseEvent* );
00218 void mouseDoubleClickEvent( QMouseEvent* );
00219 void mouseReleaseEvent( QMouseEvent* );
00220 void mouseMoveEvent( QMouseEvent* );
00221 void dragEnterEvent( QDragEnterEvent* );
00222 void dragMoveEvent( QDragMoveEvent* );
00223 void dropEvent( QDropEvent* );
00224 void showEvent ( QShowEvent *);
00225 void wheelEvent(QWheelEvent* e);
00226 void focusInEvent (QFocusEvent *);
00227 void focusOutEvent (QFocusEvent *);
00228
00229 void imStartEvent( QIMEvent *e );
00230 void imComposeEvent( QIMEvent *e );
00231 void imEndEvent( QIMEvent *e );
00232
00233 private slots:
00234 void tripleClickTimeout();
00235
00236 signals:
00237
00238 void dropEventPass(QDropEvent*);
00239
00240 private slots:
00241 void slotRegionVisibilityChangedAt(unsigned int);
00242 void slotRegionBeginEndAddedRemoved(unsigned int);
00243 void slotCodeFoldingChanged();
00244
00245 private:
00246 void moveChar( Bias bias, bool sel );
00247 void moveWord( Bias bias, bool sel );
00248 void moveEdge( Bias bias, bool sel );
00249 KateTextCursor maxStartPos(bool changed = false);
00250 void scrollPos(KateTextCursor& c, bool force = false, bool calledExternally = false);
00251 void scrollLines( int lines, bool sel );
00252
00253 uint linesDisplayed() const;
00254
00255 int lineToY(uint viewLine) const;
00256
00257 void updateSelection( const KateTextCursor&, bool keepSel );
00258 void updateCursor( const KateTextCursor& newCursor, bool force = false, bool center = false, bool calledExternally = false );
00259 void updateBracketMarks();
00260
00261 void paintCursor();
00262
00263 void placeCursor( const QPoint& p, bool keepSelection = false, bool updateSelection = true );
00264 bool isTargetSelected( const QPoint& p );
00265
00266 void doDrag();
00267
00268 KateView *m_view;
00269 KateDocument* m_doc;
00270 class KateIconBorder *leftBorder;
00271
00272 int mouseX;
00273 int mouseY;
00274 int scrollX;
00275 int scrollY;
00276
00277 KateSuperCursor cursor;
00278 KateTextCursor displayCursor;
00279 int cXPos;
00280
00281 bool possibleTripleClick;
00282
00283
00284 KateTextRange bm;
00285
00286 enum DragState { diNone, diPending, diDragging };
00287
00288 struct _dragInfo {
00289 DragState state;
00290 QPoint start;
00291 QTextDrag* dragObject;
00292 } dragInfo;
00293
00294 uint iconBorderHeight;
00295
00296
00297
00298
00299 KateScrollBar *m_lineScroll;
00300 QWidget* m_dummy;
00301 QVBoxLayout* m_lineLayout;
00302 QHBoxLayout* m_colLayout;
00303
00304
00305 KateTextCursor m_startPos;
00306 KateTextCursor m_oldStartPos;
00307
00308
00309
00310 bool m_madeVisible;
00311 bool m_shiftKeyPressed;
00312
00313
00314 void setAutoCenterLines(int viewLines, bool updateView = true);
00315 int m_autoCenterLines;
00316 int m_minLinesVisible;
00317
00318
00319
00320
00321 QScrollBar *m_columnScroll;
00322 bool m_columnScrollDisplayed;
00323 int m_startX;
00324 int m_oldStartX;
00325
00326
00327 bool m_selChangedByUser;
00328 KateTextCursor selectAnchor;
00329
00330 enum SelectionMode { Default=0, Word, Line };
00331 uint m_selectionMode;
00332
00333
00334
00335 KateTextCursor selStartCached;
00336 KateTextCursor selEndCached;
00337
00338
00339
00340
00341 QMemArray<KateLineRange> lineRanges;
00342
00343
00344 bool scrollbarVisible(uint startLine);
00345 int maxLen(uint startLine);
00346
00347
00348 int lineMaxCursorX(const KateLineRange& range);
00349 int lineMaxCol(const KateLineRange& range);
00350
00351
00352
00353 KateLineRange range(int realLine, const KateLineRange* previous = 0L);
00354
00355 KateLineRange currentRange();
00356 KateLineRange previousRange();
00357 KateLineRange nextRange();
00358
00359
00360 KateLineRange range(const KateTextCursor& realCursor);
00361
00362
00363 KateLineRange range(uint realLine, int viewLine);
00364
00365
00366 uint viewLine(const KateTextCursor& realCursor);
00367
00368
00369
00370 int displayViewLine(const KateTextCursor& virtualCursor, bool limitToVisible = false);
00371
00372
00373 uint lastViewLine(uint realLine);
00374
00375
00376 uint viewLineCount(uint realLine);
00377
00378
00379
00380
00381 KateTextCursor viewLineOffset(const KateTextCursor& virtualCursor, int offset, bool keepX = false);
00382
00383
00384 bool m_preserveMaxX;
00385 int m_currentMaxX;
00386
00387 bool m_usePlainLines;
00388 KateTextLine::Ptr textLine(int realLine);
00389
00390 bool m_updatingView;
00391 int m_wrapChangeViewLine;
00392 KateTextCursor m_cachedMaxStartPos;
00393
00394 private slots:
00395 void doDragScroll();
00396 void startDragScroll();
00397 void stopDragScroll();
00398
00399 private:
00400
00401 QTimer m_dragScrollTimer;
00402 QTimer m_scrollTimer;
00403 QTimer m_cursorTimer;
00404 QTimer m_textHintTimer;
00405
00406 static const int scrollTime = 30;
00407 static const int scrollMargin = 16;
00408
00409
00410 bool m_suppressColumnScrollBar;
00411
00412 private slots:
00413 void scrollTimeout ();
00414 void cursorTimeout ();
00415 void textHintTimeout ();
00416
00417
00418 public:
00419 void enableTextHints(int timeout);
00420 void disableTextHints();
00421
00422 private:
00423 bool m_textHintEnabled;
00424 int m_textHintTimeout;
00425 int m_textHintMouseX;
00426 int m_textHintMouseY;
00427
00428 int m_imPreeditStartLine;
00429 int m_imPreeditStart;
00430 int m_imPreeditLength;
00431 };
00432
00433 #endif
00434
00435
This file is part of the documentation for kate Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:13:33 2004 by
doxygen 1.3.8-20040913 written by
Dimitri van Heesch, © 1997-2003