• Skip to content
  • Skip to link menu
KDE 4.2 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 
00058 class KateScrollBar : public QScrollBar
00059 {
00060   Q_OBJECT
00061 
00062   public:
00063     KateScrollBar(Qt::Orientation orientation, class KateViewInternal *parent);
00064 
00065     inline bool showMarks() { return m_showMarks; }
00066     inline void setShowMarks(bool b) { m_showMarks = b; update(); }
00067 
00068   Q_SIGNALS:
00069     void sliderMMBMoved(int value);
00070 
00071   protected:
00072     virtual void mousePressEvent(QMouseEvent* e);
00073     virtual void mouseReleaseEvent(QMouseEvent* e);
00074     virtual void mouseMoveEvent (QMouseEvent* e);
00075     virtual void paintEvent(QPaintEvent *);
00076     virtual void resizeEvent(QResizeEvent *);
00077     virtual void styleChange(QStyle &oldStyle);
00078     virtual void sliderChange ( SliderChange change );
00079     virtual void wheelEvent(QWheelEvent *e);
00080 
00081   protected Q_SLOTS:
00082     void sliderMaybeMoved(int value);
00083     void marksChanged();
00084 
00085   private:
00086     void redrawMarks();
00087     void recomputeMarksPositions();
00088 
00089     bool m_middleMouseDown;
00090 
00091     KateView *m_view;
00092     KateDocument *m_doc;
00093     class KateViewInternal *m_viewInternal;
00094 
00095     int m_topMargin;
00096     int m_bottomMargin;
00097     int m_savVisibleLines;
00098 
00099     QHash<int, QColor> m_lines;
00100 
00101     bool m_showMarks;
00102 };
00103 
00104 class KateIconBorder : public QWidget
00105 {
00106   Q_OBJECT
00107 
00108   public:
00109     KateIconBorder( KateViewInternal* internalView, QWidget *parent );
00110     virtual ~KateIconBorder();
00111     // VERY IMPORTANT ;)
00112     virtual QSize sizeHint() const;
00113 
00114     void updateFont();
00115     int lineNumberWidth() const;
00116 
00117     void setIconBorderOn(       bool enable );
00118     void setLineNumbersOn(      bool enable );
00119     void setAnnotationBorderOn( bool enable );
00120     void setDynWrapIndicators(int state );
00121     int dynWrapIndicators()  const { return m_dynWrapIndicators; }
00122     bool dynWrapIndicatorsOn() const { return m_dynWrapIndicatorsOn; }
00123     void setFoldingMarkersOn( bool enable );
00124     void toggleIconBorder()     { setIconBorderOn(     !iconBorderOn() );     }
00125     void toggleLineNumbers()    { setLineNumbersOn(    !lineNumbersOn() );    }
00126     void toggleFoldingMarkers() { setFoldingMarkersOn( !foldingMarkersOn() ); }
00127     inline bool iconBorderOn()       const { return m_iconBorderOn;       }
00128     inline bool lineNumbersOn()      const { return m_lineNumbersOn;      }
00129     inline bool foldingMarkersOn()   const { return m_foldingMarkersOn;   }
00130     inline bool annotationBorderOn() const { return m_annotationBorderOn; }
00131 
00132     enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder };
00133     BorderArea positionToArea( const QPoint& ) const;
00134 
00135   Q_SIGNALS:
00136     void toggleRegionVisibility( unsigned int );
00137   public Q_SLOTS:
00138     void updateAnnotationBorderWidth();
00139     void updateAnnotationLine( int line );
00140     void annotationModelChanged( KTextEditor::AnnotationModel* oldmodel, KTextEditor::AnnotationModel* newmodel );
00141 
00142   private:
00143     void paintEvent( QPaintEvent* );
00144     void paintBorder (int x, int y, int width, int height);
00145 
00146     void mousePressEvent( QMouseEvent* );
00147     void mouseMoveEvent( QMouseEvent* );
00148     void mouseReleaseEvent( QMouseEvent* );
00149     void mouseDoubleClickEvent( QMouseEvent* );
00150     void leaveEvent(QEvent *event);
00151 
00152     void showMarkMenu( uint line, const QPoint& pos );
00153 
00154     void showAnnotationTooltip( int line, const QPoint& pos );
00155     void hideAnnotationTooltip();
00156     void removeAnnotationHovering();
00157     void showAnnotationMenu( int line, const QPoint& pos);
00158     int annotationLineWidth( int line );
00159 
00160     KateView *m_view;
00161     KateDocument *m_doc;
00162     KateViewInternal *m_viewInternal;
00163 
00164     bool m_iconBorderOn:1;
00165     bool m_lineNumbersOn:1;
00166     bool m_foldingMarkersOn:1;
00167     bool m_dynWrapIndicatorsOn:1;
00168     bool m_annotationBorderOn:1;
00169     int m_dynWrapIndicators;
00170 
00171     int m_lastClickedLine;
00172 
00173     int m_cachedLNWidth;
00174 
00175     int m_maxCharWidth;
00176     int iconPaneWidth;
00177     int m_annotationBorderWidth;
00178 
00179     mutable QPixmap m_arrow;
00180     mutable QColor m_oldBackgroundColor;
00181 
00182     KTextEditor::SmartRange *m_foldingRange;
00183     int m_lastBlockLine;
00184     void showBlock(int line);
00185     void hideBlock();
00186 
00187     QColor m_foldingColors[MAXFOLDINGCOLORS];
00188     QBrush foldingColor(KateLineInfo *, int,bool solid);
00189     QString m_hoveredAnnotationText;
00190     
00191     void initializeFoldingColors();
00192 };
00193 
00194 class KateViewEncodingAction: public KSelectAction
00195 {
00196   Q_OBJECT
00197   
00198   Q_PROPERTY(QString codecName READ currentCodecName WRITE setCurrentCodec)
00199   Q_PROPERTY(int codecMib READ currentCodecMib)
00200   
00201   public:
00202     KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent);
00203 
00204     ~KateViewEncodingAction();
00205     
00206     KEncodingProber::ProberType currentProberType() const;
00207 
00208     bool setCurrentProberType(KEncodingProber::ProberType);
00209     
00210     int mibForName(const QString &codecName, bool *ok = 0) const;
00211     QTextCodec *codecForMib(int mib) const;
00212     
00213     QTextCodec *currentCodec() const;
00214     bool setCurrentCodec(QTextCodec *codec);
00215     
00216     QString currentCodecName() const;
00217     bool setCurrentCodec(const QString &codecName);
00218     
00219     int currentCodecMib() const;
00220     bool setCurrentCodec(int mib);
00221     
00222   Q_SIGNALS:
00226     void triggered(QTextCodec *codec);
00227     
00233     void triggered(const QString&);
00234         
00240     void triggered(KEncodingProber::ProberType);
00241         
00242   protected Q_SLOTS:
00243     virtual void actionTriggered(QAction*);    
00244     
00245   private:
00246     KateDocument* doc;
00247     KateView *view;
00248     class Private;
00249     Private* const d;
00250     Q_PRIVATE_SLOT( d, void _k_subActionTriggered(QAction*) )
00251     
00252   private Q_SLOTS:
00253     void setEncoding (const QString &e);
00254     void setProberTypeForEncodingAutoDetection (KEncodingProber::ProberType);
00255     void slotAboutToShow();
00256 };
00257 
00258 class KateViewBar;
00259 
00260 class KateViewBarWidget : public QWidget
00261 {
00262   Q_OBJECT
00263 
00264   public:
00265     explicit KateViewBarWidget (bool addCloseButton, KateView* view, QWidget* parent = 0);
00266 
00267     virtual void closed(){};
00268   protected:
00272     QWidget *centralWidget() { return m_centralWidget; }
00273     KateView* view() { return m_view; }
00274 
00275   signals:
00276     void hideMe();
00277 
00278   private:
00279     QWidget *m_centralWidget;
00280     KateView* m_view;
00281 };
00282 
00283 // Helper layout class to always provide minimum size
00284 class KateStackedWidget : public QStackedWidget
00285 {
00286   Q_OBJECT
00287 public:
00288   KateStackedWidget(QWidget* parent);
00289   virtual QSize sizeHint() const;
00290   virtual QSize minimumSize() const;
00291 };
00292 
00293 class QVBoxLayout;
00294 
00295 class KateViewBar : public QWidget
00296 {
00297   Q_OBJECT
00298 
00299   public:
00300     KateViewBar (bool external, KTextEditor::ViewBarContainer::Position pos,QWidget *parent,KateView *view);
00301 
00302 
00308     void addBarWidget (KateViewBarWidget *newBarWidget);
00313     void showBarWidget (KateViewBarWidget *barWidget);
00314 
00326     void addPermanentBarWidget (KateViewBarWidget *barWidget);
00333     void removePermanentBarWidget (KateViewBarWidget *barWidget);
00337     bool hasPermanentWidget (KateViewBarWidget *barWidget) const;
00338 
00339   public Q_SLOTS:
00343     void hideCurrentBarWidget();
00344 
00345   protected:
00346     virtual void keyPressEvent(QKeyEvent* event);
00347     virtual void hideEvent(QHideEvent* event);
00348 
00349   private:
00350     bool hasWidget(KateViewBarWidget*) const;
00354     void setViewBarVisible(bool visible);
00355 
00356     bool m_external;
00357     KTextEditor::ViewBarContainer::Position m_pos;
00358 
00359   private:
00360     KateView *m_view;
00361     KateStackedWidget *m_stack;
00362     KateViewBarWidget *m_permanentBarWidget;
00363     QVBoxLayout *m_layout;
00364 };
00365 
00366 class KateCmdLine : public KateViewBarWidget
00367 {
00368   public:
00369     explicit KateCmdLine(KateView *view, QWidget *parent = 0);
00370     ~KateCmdLine();
00371 
00372   void setText(const QString &text);
00373 
00374   private:
00375     class KateCmdLineEdit *m_lineEdit;
00376 };
00377 
00378 class KateCmdLineEdit : public KLineEdit
00379 {
00380   Q_OBJECT
00381 
00382   public:
00383     KateCmdLineEdit (KateCmdLine *bar, KateView *view);
00384     virtual bool event(QEvent *e);
00385 
00386     void hideEvent (QHideEvent *e);
00387 
00388   signals:
00389     void hideRequested();
00390 
00391   private Q_SLOTS:
00392     void hideLineEdit();
00393     void slotReturnPressed ( const QString& cmd );
00394 
00395   protected:
00396     void focusInEvent ( QFocusEvent *ev );
00397     void keyPressEvent( QKeyEvent *ev );
00398 
00399   private:
00400     void fromHistory( bool up );
00401     QString helptext( const QPoint & ) const;
00402 
00403     KateView *m_view;
00404     KateCmdLine *m_bar;
00405     bool m_msgMode;
00406     QString m_oldText;
00407     uint m_histpos; 
00408     uint m_cmdend; 
00409     KTextEditor::Command *m_command; 
00410     class KCompletion *m_oldCompletionObject; 
00411     class KateCmdLnWhatsThis *m_help;
00412     QRegExp m_cmdRange;
00413     QRegExp m_gotoLine;
00414 };
00415 
00416 #endif
00417 
00418 // 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
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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