• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

kateviewhelpers.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
00003    Copyright (C) 2001 Anders Lund <anders@alweb.dk>
00004    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __KATE_VIEW_HELPERS_H__
00022 #define __KATE_VIEW_HELPERS_H__
00023 
00024 #include <kselectaction.h>
00025 #include <kencodingprober.h>
00026 #include <klineedit.h>
00027 
00028 #include <QtGui/QPixmap>
00029 #include <QtGui/QColor>
00030 #include <QtGui/QScrollBar>
00031 #include <QtCore/QHash>
00032 #include <QtGui/QStackedWidget>
00033 #include <QtCore/QMap>
00034 
00035 #include <ktexteditor/containerinterface.h>
00036 
00037 class KateDocument;
00038 class KateView;
00039 class KateViewInternal;
00040 
00041 #define MAXFOLDINGCOLORS 16
00042 
00043 class KateLineInfo;
00044 
00045 namespace KTextEditor {
00046   class Command;
00047   class SmartRange;
00048   class AnnotationModel;
00049 }
00050 
00051 class QTimer;
00052 
00060 class KateScrollBar : public QScrollBar
00061 {
00062   Q_OBJECT
00063 
00064   public:
00065     KateScrollBar(Qt::Orientation orientation, class KateViewInternal *parent);
00066 
00067     inline bool showMarks() { return m_showMarks; }
00068     inline void setShowMarks(bool b) { m_showMarks = b; update(); }
00069 
00070   Q_SIGNALS:
00071     void sliderMMBMoved(int value);
00072 
00073   protected:
00074     virtual void mousePressEvent(QMouseEvent* e);
00075     virtual void mouseReleaseEvent(QMouseEvent* e);
00076     virtual void mouseMoveEvent (QMouseEvent* e);
00077     virtual void paintEvent(QPaintEvent *);
00078     virtual void resizeEvent(QResizeEvent *);
00079     virtual void styleChange(QStyle &oldStyle);
00080     virtual void sliderChange ( SliderChange change );
00081     virtual void wheelEvent(QWheelEvent *e);
00082 
00083   protected Q_SLOTS:
00084     void sliderMaybeMoved(int value);
00085     void marksChanged();
00086 
00087   private:
00088     void redrawMarks();
00089     void recomputeMarksPositions();
00090 
00091     bool m_middleMouseDown;
00092 
00093     KateView *m_view;
00094     KateDocument *m_doc;
00095     class KateViewInternal *m_viewInternal;
00096 
00097     int m_topMargin;
00098     int m_bottomMargin;
00099     int m_savVisibleLines;
00100 
00101     QHash<int, QColor> m_lines;
00102 
00103     bool m_showMarks;
00104 };
00105 
00106 class KateIconBorder : public QWidget
00107 {
00108   Q_OBJECT
00109 
00110   public:
00111     KateIconBorder( KateViewInternal* internalView, QWidget *parent );
00112     virtual ~KateIconBorder();
00113     // VERY IMPORTANT ;)
00114     virtual QSize sizeHint() const;
00115 
00116     void updateFont();
00117     int lineNumberWidth() const;
00118 
00119     void setIconBorderOn(       bool enable );
00120     void setLineNumbersOn(      bool enable );
00121     void setAnnotationBorderOn( bool enable );
00122     void setDynWrapIndicators(int state );
00123     int dynWrapIndicators()  const { return m_dynWrapIndicators; }
00124     bool dynWrapIndicatorsOn() const { return m_dynWrapIndicatorsOn; }
00125     void setFoldingMarkersOn( bool enable );
00126     void toggleIconBorder()     { setIconBorderOn(     !iconBorderOn() );     }
00127     void toggleLineNumbers()    { setLineNumbersOn(    !lineNumbersOn() );    }
00128     void toggleFoldingMarkers() { setFoldingMarkersOn( !foldingMarkersOn() ); }
00129     inline bool iconBorderOn()       const { return m_iconBorderOn;       }
00130     inline bool lineNumbersOn()      const { return m_lineNumbersOn;      }
00131     inline bool foldingMarkersOn()   const { return m_foldingMarkersOn;   }
00132     inline bool annotationBorderOn() const { return m_annotationBorderOn; }
00133 
00134     enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder };
00135     BorderArea positionToArea( const QPoint& ) const;
00136 
00137   Q_SIGNALS:
00138     void toggleRegionVisibility( unsigned int );
00139   public Q_SLOTS:
00140     void updateAnnotationBorderWidth();
00141     void updateAnnotationLine( int line );
00142     void annotationModelChanged( KTextEditor::AnnotationModel* oldmodel, KTextEditor::AnnotationModel* newmodel );
00143 
00144   private:
00145     void paintEvent( QPaintEvent* );
00146     void paintBorder (int x, int y, int width, int height);
00147 
00148     void mousePressEvent( QMouseEvent* );
00149     void mouseMoveEvent( QMouseEvent* );
00150     void mouseReleaseEvent( QMouseEvent* );
00151     void mouseDoubleClickEvent( QMouseEvent* );
00152     void leaveEvent(QEvent *event);
00153 
00154     void showMarkMenu( uint line, const QPoint& pos );
00155 
00156     void showAnnotationTooltip( int line, const QPoint& pos );
00157     void hideAnnotationTooltip();
00158     void removeAnnotationHovering();
00159     void showAnnotationMenu( int line, const QPoint& pos);
00160     int annotationLineWidth( int line );
00161 
00162     KateView *m_view;
00163     KateDocument *m_doc;
00164     KateViewInternal *m_viewInternal;
00165 
00166     bool m_iconBorderOn:1;
00167     bool m_lineNumbersOn:1;
00168     bool m_foldingMarkersOn:1;
00169     bool m_dynWrapIndicatorsOn:1;
00170     bool m_annotationBorderOn:1;
00171     int m_dynWrapIndicators;
00172 
00173     int m_lastClickedLine;
00174 
00175     int m_cachedLNWidth;
00176 
00177     int m_maxCharWidth;
00178     int iconPaneWidth;
00179     int m_annotationBorderWidth;
00180 
00181     mutable QPixmap m_arrow;
00182     mutable QColor m_oldBackgroundColor;
00183 
00184 
00185     KTextEditor::SmartRange *m_foldingRange;
00186     int m_nextHighlightBlock;
00187     int m_currentBlockLine;
00188     QTimer* m_delayFoldingHlTimer;
00189     void showDelayedBlock(int line);
00190     void hideBlock();
00191 
00192   private Q_SLOTS:
00193     void showBlock();
00194 
00195   private:
00196     QColor m_foldingColors[MAXFOLDINGCOLORS];
00197     QBrush foldingColor(KateLineInfo *, int,bool solid);
00198     QString m_hoveredAnnotationText;
00199 
00200     void initializeFoldingColors();
00201 };
00202 
00203 class KateViewEncodingAction: public KSelectAction
00204 {
00205   Q_OBJECT
00206 
00207   Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec)
00208   Q_PROPERTY(int codecMib READ currentCodecMib)
00209 
00210   public:
00211     KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent);
00212 
00213     ~KateViewEncodingAction();
00214 
00215     KEncodingProber::ProberType currentProberType() const;
00216 
00217     bool setCurrentProberType(KEncodingProber::ProberType);
00218 
00219     int mibForName(const QString &codecName, bool *ok = 0) const;
00220     QTextCodec *codecForMib(int mib) const;
00221 
00222     QTextCodec *currentCodec() const;
00223     bool setCurrentCodec(QTextCodec *codec);
00224 
00225     QString currentCodecName() const;
00226     bool setCurrentCodec(const QString &codecName);
00227 
00228     int currentCodecMib() const;
00229     bool setCurrentCodec(int mib);
00230 
00231   Q_SIGNALS:
00235     void triggered(QTextCodec *codec);
00236 
00242     void triggered(const QString&);
00243 
00249     void triggered(KEncodingProber::ProberType);
00250 
00251   protected Q_SLOTS:
00252     virtual void actionTriggered(QAction*);
00253 
00254   private:
00255     KateDocument* doc;
00256     KateView *view;
00257     class Private;
00258     Private* const d;
00259     Q_PRIVATE_SLOT( d, void _k_subActionTriggered(QAction*) )
00260 
00261   private Q_SLOTS:
00262     void setEncoding (const QString &e);
00263     void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00264     void slotAboutToShow();
00265 };
00266 
00267 class KateViewBar;
00268 
00269 class KateViewBarWidget : public QWidget
00270 {
00271   Q_OBJECT
00272 
00273   public:
00274     explicit KateViewBarWidget (bool addCloseButton, KateView* view, QWidget* parent = 0);
00275 
00276     virtual void closed(){};
00277   protected:
00281     QWidget *centralWidget() { return m_centralWidget; }
00282     KateView* view() { return m_view; }
00283 
00284   signals:
00285     void hideMe();
00286 
00287   private:
00288     QWidget *m_centralWidget;
00289     KateView* m_view;
00290 };
00291 
00292 // Helper layout class to always provide minimum size
00293 class KateStackedWidget : public QStackedWidget
00294 {
00295   Q_OBJECT
00296 public:
00297   KateStackedWidget(QWidget* parent);
00298   virtual QSize sizeHint() const;
00299   virtual QSize minimumSize() const;
00300 };
00301 
00302 class QVBoxLayout;
00303 
00304 class KateViewBar : public QWidget
00305 {
00306   Q_OBJECT
00307 
00308   public:
00309     KateViewBar (bool external, KTextEditor::ViewBarContainer::Position pos,QWidget *parent,KateView *view);
00310 
00311 
00317     void addBarWidget (KateViewBarWidget *newBarWidget);
00322     void showBarWidget (KateViewBarWidget *barWidget);
00323 
00335     void addPermanentBarWidget (KateViewBarWidget *barWidget);
00342     void removePermanentBarWidget (KateViewBarWidget *barWidget);
00346     bool hasPermanentWidget (KateViewBarWidget *barWidget) const;
00347 
00348   public Q_SLOTS:
00352     void hideCurrentBarWidget();
00353 
00354   protected:
00355     virtual void keyPressEvent(QKeyEvent* event);
00356     virtual void hideEvent(QHideEvent* event);
00357 
00358   private:
00359     bool hasWidget(KateViewBarWidget*) const;
00363     void setViewBarVisible(bool visible);
00364 
00365     bool m_external;
00366     KTextEditor::ViewBarContainer::Position m_pos;
00367 
00368   private:
00369     KateView *m_view;
00370     KateStackedWidget *m_stack;
00371     KateViewBarWidget *m_permanentBarWidget;
00372     QVBoxLayout *m_layout;
00373 };
00374 
00375 class KateCmdLine : public KateViewBarWidget
00376 {
00377   public:
00378     explicit KateCmdLine(KateView *view, QWidget *parent = 0);
00379     ~KateCmdLine();
00380 
00381   void setText(const QString &text, bool selected = true);
00382 
00383   private:
00384     class KateCmdLineEdit *m_lineEdit;
00385 };
00386 
00387 class KateCmdLineEdit : public KLineEdit
00388 {
00389   Q_OBJECT
00390 
00391   public:
00392     KateCmdLineEdit (KateCmdLine *bar, KateView *view);
00393     virtual bool event(QEvent *e);
00394 
00395     void hideEvent (QHideEvent *e);
00396 
00397   signals:
00398     void hideRequested();
00399 
00400   private Q_SLOTS:
00401     void hideLineEdit();
00402     void slotReturnPressed ( const QString& cmd );
00403 
00404   protected:
00405     void focusInEvent ( QFocusEvent *ev );
00406     void keyPressEvent( QKeyEvent *ev );
00407 
00408   private:
00409     void fromHistory( bool up );
00410     QString helptext( const QPoint & ) const;
00411 
00412     KateView *m_view;
00413     KateCmdLine *m_bar;
00414     bool m_msgMode;
00415     QString m_oldText;
00416     uint m_histpos; 
00417     uint m_cmdend; 
00418     KTextEditor::Command *m_command; 
00419     class KCompletion *m_oldCompletionObject; 
00420     class KateCmdLnWhatsThis *m_help;
00421     QRegExp m_cmdRange;
00422     QRegExp m_cmdExpr;
00423     QRegExp m_gotoLine;
00424     QTimer *m_hideTimer;
00425 };
00426 
00427 #endif
00428 
00429 // kate: space-indent on; indent-width 2; replace-tabs on;

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  •     Sodep
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal