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