• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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 #include <QtCore/QTimer>
00035 
00036 #include <ktexteditor/containerinterface.h>
00037 
00038 class KateDocument;
00039 class KateView;
00040 class KateViewInternal;
00041 
00042 #define MAXFOLDINGCOLORS 16
00043 
00044 class KateLineInfo;
00045 
00046 namespace KTextEditor {
00047   class Command;
00048   class SmartRange;
00049   class AnnotationModel;
00050   class MovingRange;
00051 }
00052 
00053 class QTimer;
00054 class QVBoxLayout;
00055 
00063 class KateScrollBar : public QScrollBar
00064 {
00065   Q_OBJECT
00066 
00067   public:
00068     KateScrollBar(Qt::Orientation orientation, class KateViewInternal *parent);
00069 
00070     inline bool showMarks() { return m_showMarks; }
00071     inline void setShowMarks(bool b) { m_showMarks = b; update(); }
00072 
00073   Q_SIGNALS:
00074     void sliderMMBMoved(int value);
00075 
00076   protected:
00077     virtual void mousePressEvent(QMouseEvent* e);
00078     virtual void mouseReleaseEvent(QMouseEvent* e);
00079     virtual void mouseMoveEvent (QMouseEvent* e);
00080     virtual void paintEvent(QPaintEvent *);
00081     virtual void resizeEvent(QResizeEvent *);
00082     virtual void styleChange(QStyle &oldStyle);
00083     virtual void sliderChange ( SliderChange change );
00084     virtual void wheelEvent(QWheelEvent *e);
00085 
00086   protected Q_SLOTS:
00087     void sliderMaybeMoved(int value);
00088     void marksChanged();
00089 
00090   private:
00091     void redrawMarks();
00092     void recomputeMarksPositions();
00093 
00094     bool m_middleMouseDown;
00095 
00096     KateView *m_view;
00097     KateDocument *m_doc;
00098     class KateViewInternal *m_viewInternal;
00099 
00100     QHash<int, QColor> m_lines;
00101 
00102     bool m_showMarks;
00103 };
00104 
00105 class KateIconBorder : public QWidget
00106 {
00107   Q_OBJECT
00108 
00109   public:
00110     KateIconBorder( KateViewInternal* internalView, QWidget *parent );
00111     virtual ~KateIconBorder();
00112     // VERY IMPORTANT ;)
00113     virtual QSize sizeHint() const;
00114 
00115     void updateFont();
00116     int lineNumberWidth() const;
00117 
00118     void setIconBorderOn(       bool enable );
00119     void setLineNumbersOn(      bool enable );
00120     void setAnnotationBorderOn( bool enable );
00121     void setDynWrapIndicators(int state );
00122     int dynWrapIndicators()  const { return m_dynWrapIndicators; }
00123     bool dynWrapIndicatorsOn() const { return m_dynWrapIndicatorsOn; }
00124     void setFoldingMarkersOn( bool enable );
00125     void toggleIconBorder()     { setIconBorderOn(     !iconBorderOn() );     }
00126     void toggleLineNumbers()    { setLineNumbersOn(    !lineNumbersOn() );    }
00127     void toggleFoldingMarkers() { setFoldingMarkersOn( !foldingMarkersOn() ); }
00128     inline bool iconBorderOn()       const { return m_iconBorderOn;       }
00129     inline bool lineNumbersOn()      const { return m_lineNumbersOn;      }
00130     inline bool foldingMarkersOn()   const { return m_foldingMarkersOn;   }
00131     inline bool annotationBorderOn() const { return m_annotationBorderOn; }
00132 
00133     enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder };
00134     BorderArea positionToArea( const QPoint& ) const;
00135 
00136   Q_SIGNALS:
00137     void toggleRegionVisibility( unsigned int );
00138   public Q_SLOTS:
00139     void updateAnnotationBorderWidth();
00140     void updateAnnotationLine( int line );
00141     void annotationModelChanged( KTextEditor::AnnotationModel* oldmodel, KTextEditor::AnnotationModel* newmodel );
00142 
00143   private:
00144     void paintEvent( QPaintEvent* );
00145     void paintBorder (int x, int y, int width, int height);
00146 
00147     void mousePressEvent( QMouseEvent* );
00148     void mouseMoveEvent( QMouseEvent* );
00149     void mouseReleaseEvent( QMouseEvent* );
00150     void mouseDoubleClickEvent( QMouseEvent* );
00151     void leaveEvent(QEvent *event);
00152 
00153     void showMarkMenu( uint line, const QPoint& pos );
00154 
00155     void showAnnotationTooltip( int line, const QPoint& pos );
00156     void hideAnnotationTooltip();
00157     void removeAnnotationHovering();
00158     void showAnnotationMenu( int line, const QPoint& pos);
00159     int annotationLineWidth( int line );
00160 
00161     KateView *m_view;
00162     KateDocument *m_doc;
00163     KateViewInternal *m_viewInternal;
00164 
00165     bool m_iconBorderOn:1;
00166     bool m_lineNumbersOn:1;
00167     bool m_foldingMarkersOn:1;
00168     bool m_dynWrapIndicatorsOn:1;
00169     bool m_annotationBorderOn:1;
00170     int m_dynWrapIndicators;
00171 
00172     int m_lastClickedLine;
00173 
00174     int m_cachedLNWidth;
00175 
00176     int m_maxCharWidth;
00177     int iconPaneWidth;
00178     int m_annotationBorderWidth;
00179 
00180     mutable QPixmap m_arrow;
00181     mutable QColor m_oldBackgroundColor;
00182 
00183 
00184     KTextEditor::MovingRange *m_foldingRange;
00185     int m_nextHighlightBlock;
00186     int m_currentBlockLine;
00187     QTimer m_delayFoldingHlTimer;
00188     void showDelayedBlock(int line);
00189     void hideBlock();
00190 
00191   private Q_SLOTS:
00192     void showBlock();
00193 
00194   private:
00195     QColor m_foldingColors[MAXFOLDINGCOLORS];
00196     QBrush foldingColor(KateLineInfo *, int,bool solid);
00197     QString m_hoveredAnnotationText;
00198 
00199     void initializeFoldingColors();
00200 };
00201 
00202 class KateViewEncodingAction: public KSelectAction
00203 {
00204   Q_OBJECT
00205 
00206   Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec)
00207   Q_PROPERTY(int codecMib READ currentCodecMib)
00208 
00209   public:
00210     KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent);
00211 
00212     ~KateViewEncodingAction();
00213 
00214     int mibForName(const QString &codecName, bool *ok = 0) const;
00215     QTextCodec *codecForMib(int mib) const;
00216 
00217     QTextCodec *currentCodec() const;
00218     bool setCurrentCodec(QTextCodec *codec);
00219 
00220     QString currentCodecName() const;
00221     bool setCurrentCodec(const QString &codecName);
00222 
00223     int currentCodecMib() const;
00224     bool setCurrentCodec(int mib);
00225 
00226   Q_SIGNALS:
00230     void triggered(QTextCodec *codec);
00231 
00232   private:
00233     KateDocument* doc;
00234     KateView *view;
00235     class Private;
00236     Private* const d;
00237     Q_PRIVATE_SLOT( d, void _k_subActionTriggered(QAction*) )
00238 
00239   private Q_SLOTS:
00240     void setEncoding (const QString &e);
00241     void slotAboutToShow();
00242 };
00243 
00244 class KateViewBar;
00245 
00246 class KateViewBarWidget : public QWidget
00247 {
00248   Q_OBJECT
00249 
00250   public:
00251     explicit KateViewBarWidget (bool addCloseButton, QWidget* parent = 0);
00252 
00253     virtual void closed(){};
00254   protected:
00258     QWidget *centralWidget() { return m_centralWidget; }
00259 
00260   signals:
00261     void hideMe();
00262 
00263   private:
00264     QWidget *m_centralWidget;
00265 };
00266 
00267 class KateViewBar : public QWidget
00268 {
00269   Q_OBJECT
00270 
00271   public:
00272     KateViewBar (bool external, 
00273                  KTextEditor::ViewBarContainer::Position pos,
00274                  QWidget *parent,
00275                  KateView *view);
00276 
00277 
00283     void addBarWidget (KateViewBarWidget *newBarWidget);
00284 
00291     void removeBarWidget (KateViewBarWidget *barWidget);
00292     
00296     bool hasBarWidget(KateViewBarWidget* barWidget) const;
00297 
00302     void showBarWidget (KateViewBarWidget *barWidget);
00303 
00315     void addPermanentBarWidget (KateViewBarWidget *barWidget);
00316 
00323     void removePermanentBarWidget (KateViewBarWidget *barWidget);
00324 
00328     bool hasPermanentWidget (KateViewBarWidget *barWidget) const;
00329 
00330   public Q_SLOTS:
00334     void hideCurrentBarWidget();
00335 
00336   protected:
00337     virtual void keyPressEvent(QKeyEvent* event);
00338     virtual void hideEvent(QHideEvent* event);
00339 
00340   private:
00344     void setViewBarVisible(bool visible);
00345 
00346     bool m_external;
00347     KTextEditor::ViewBarContainer::Position m_pos;
00348 
00349   private:
00350     KateView *m_view;
00351     QStackedWidget *m_stack;
00352     KateViewBarWidget *m_permanentBarWidget;
00353     QVBoxLayout *m_layout;
00354 };
00355 
00356 class KateCommandLineBar : public KateViewBarWidget
00357 {
00358   public:
00359     explicit KateCommandLineBar(KateView *view, QWidget *parent = 0);
00360     ~KateCommandLineBar();
00361 
00362     void setText(const QString &text, bool selected = true);
00363     void execute(const QString &text);
00364 
00365   private:
00366     class KateCmdLineEdit *m_lineEdit;
00367 };
00368 
00369 class KateCmdLineEdit : public KLineEdit
00370 {
00371   Q_OBJECT
00372 
00373   public:
00374     KateCmdLineEdit (KateCommandLineBar *bar, KateView *view);
00375     virtual bool event(QEvent *e);
00376 
00377     void hideEvent (QHideEvent *e);
00378 
00379   signals:
00380     void hideRequested();
00381     
00382   public Q_SLOTS:
00383     void slotReturnPressed ( const QString& cmd );
00384 
00385   private Q_SLOTS:
00386     void hideLineEdit();
00387 
00388   protected:
00389     void focusInEvent ( QFocusEvent *ev );
00390     void keyPressEvent( QKeyEvent *ev );
00391 
00392   private:
00393     void fromHistory( bool up );
00394     QString helptext( const QPoint & ) const;
00395 
00396     KateView *m_view;
00397     KateCommandLineBar *m_bar;
00398     bool m_msgMode;
00399     QString m_oldText;
00400     uint m_histpos; 
00401     uint m_cmdend; 
00402     KTextEditor::Command *m_command; 
00403     class KateCmdLnWhatsThis *m_help;
00404     QRegExp m_cmdRange;
00405     QRegExp m_cmdExpr;
00406     QRegExp m_gotoLine;
00407     QTimer *m_hideTimer;
00408 };
00409 
00410 #endif
00411 
00412 // 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
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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