• Skip to content
  • Skip to link menu
KDE 4.3 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     KTextEditor::SmartRange *m_foldingRange;
00185     int m_lastBlockLine;
00186     void showBlock(int line);
00187     void hideBlock();
00188 
00189     QColor m_foldingColors[MAXFOLDINGCOLORS];
00190     QBrush foldingColor(KateLineInfo *, int,bool solid);
00191     QString m_hoveredAnnotationText;
00192     
00193     void initializeFoldingColors();
00194 };
00195 
00196 class KateViewEncodingAction: public KSelectAction
00197 {
00198   Q_OBJECT
00199   
00200   Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec)
00201   Q_PROPERTY(int codecMib READ currentCodecMib)
00202   
00203   public:
00204     KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent);
00205 
00206     ~KateViewEncodingAction();
00207     
00208     KEncodingProber::ProberType currentProberType() const;
00209 
00210     bool setCurrentProberType(KEncodingProber::ProberType);
00211     
00212     int mibForName(const QString &codecName, bool *ok = 0) const;
00213     QTextCodec *codecForMib(int mib) const;
00214     
00215     QTextCodec *currentCodec() const;
00216     bool setCurrentCodec(QTextCodec *codec);
00217     
00218     QString currentCodecName() const;
00219     bool setCurrentCodec(const QString &codecName);
00220     
00221     int currentCodecMib() const;
00222     bool setCurrentCodec(int mib);
00223     
00224   Q_SIGNALS:
00228     void triggered(QTextCodec *codec);
00229     
00235     void triggered(const QString&);
00236         
00242     void triggered(KEncodingProber::ProberType);
00243         
00244   protected Q_SLOTS:
00245     virtual void actionTriggered(QAction*);    
00246     
00247   private:
00248     KateDocument* doc;
00249     KateView *view;
00250     class Private;
00251     Private* const d;
00252     Q_PRIVATE_SLOT( d, void _k_subActionTriggered(QAction*) )
00253     
00254   private Q_SLOTS:
00255     void setEncoding (const QString &e);
00256     void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00257     void slotAboutToShow();
00258 };
00259 
00260 class KateViewBar;
00261 
00262 class KateViewBarWidget : public QWidget
00263 {
00264   Q_OBJECT
00265 
00266   public:
00267     explicit KateViewBarWidget (bool addCloseButton, KateView* view, QWidget* parent = 0);
00268 
00269     virtual void closed(){};
00270   protected:
00274     QWidget *centralWidget() { return m_centralWidget; }
00275     KateView* view() { return m_view; }
00276 
00277   signals:
00278     void hideMe();
00279 
00280   private:
00281     QWidget *m_centralWidget;
00282     KateView* m_view;
00283 };
00284 
00285 // Helper layout class to always provide minimum size
00286 class KateStackedWidget : public QStackedWidget
00287 {
00288   Q_OBJECT
00289 public:
00290   KateStackedWidget(QWidget* parent);
00291   virtual QSize sizeHint() const;
00292   virtual QSize minimumSize() const;
00293 };
00294 
00295 class QVBoxLayout;
00296 
00297 class KateViewBar : public QWidget
00298 {
00299   Q_OBJECT
00300 
00301   public:
00302     KateViewBar (bool external, KTextEditor::ViewBarContainer::Position pos,QWidget *parent,KateView *view);
00303 
00304 
00310     void addBarWidget (KateViewBarWidget *newBarWidget);
00315     void showBarWidget (KateViewBarWidget *barWidget);
00316 
00328     void addPermanentBarWidget (KateViewBarWidget *barWidget);
00335     void removePermanentBarWidget (KateViewBarWidget *barWidget);
00339     bool hasPermanentWidget (KateViewBarWidget *barWidget) const;
00340 
00341   public Q_SLOTS:
00345     void hideCurrentBarWidget();
00346 
00347   protected:
00348     virtual void keyPressEvent(QKeyEvent* event);
00349     virtual void hideEvent(QHideEvent* event);
00350 
00351   private:
00352     bool hasWidget(KateViewBarWidget*) const;
00356     void setViewBarVisible(bool visible);
00357 
00358     bool m_external;
00359     KTextEditor::ViewBarContainer::Position m_pos;
00360 
00361   private:
00362     KateView *m_view;
00363     KateStackedWidget *m_stack;
00364     KateViewBarWidget *m_permanentBarWidget;
00365     QVBoxLayout *m_layout;
00366 };
00367 
00368 class KateCmdLine : public KateViewBarWidget
00369 {
00370   public:
00371     explicit KateCmdLine(KateView *view, QWidget *parent = 0);
00372     ~KateCmdLine();
00373 
00374   void setText(const QString &text);
00375 
00376   private:
00377     class KateCmdLineEdit *m_lineEdit;
00378 };
00379 
00380 class KateCmdLineEdit : public KLineEdit
00381 {
00382   Q_OBJECT
00383 
00384   public:
00385     KateCmdLineEdit (KateCmdLine *bar, KateView *view);
00386     virtual bool event(QEvent *e);
00387 
00388     void hideEvent (QHideEvent *e);
00389 
00390   signals:
00391     void hideRequested();
00392 
00393   private Q_SLOTS:
00394     void hideLineEdit();
00395     void slotReturnPressed ( const QString& cmd );
00396 
00397   protected:
00398     void focusInEvent ( QFocusEvent *ev );
00399     void keyPressEvent( QKeyEvent *ev );
00400 
00401   private:
00402     void fromHistory( bool up );
00403     QString helptext( const QPoint & ) const;
00404 
00405     KateView *m_view;
00406     KateCmdLine *m_bar;
00407     bool m_msgMode;
00408     QString m_oldText;
00409     uint m_histpos; 
00410     uint m_cmdend; 
00411     KTextEditor::Command *m_command; 
00412     class KCompletion *m_oldCompletionObject; 
00413     class KateCmdLnWhatsThis *m_help;
00414     QRegExp m_cmdRange;
00415     QRegExp m_gotoLine;
00416     QTimer *m_hideTimer;
00417 };
00418 
00419 #endif
00420 
00421 // 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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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