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