• Skip to content
  • Skip to link menu
KDE 4.1 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 <kcodecaction.h>
00025 #include <klineedit.h>
00026 
00027 #include <QtGui/QPixmap>
00028 #include <QtGui/QColor>
00029 #include <QtGui/QScrollBar>
00030 #include <QtCore/QHash>
00031 #include <QtGui/QStackedLayout>
00032 #include <QtCore/QMap>
00033 
00034 class KateDocument;
00035 class KateView;
00036 class KateViewInternal;
00037 
00038 #define MAXFOLDINGCOLORS 16
00039 
00040 class KateLineInfo;
00041 
00042 namespace KTextEditor {
00043   class Command;
00044   class SmartRange;
00045   class AnnotationModel;
00046 }
00047 
00055 class KateScrollBar : public QScrollBar
00056 {
00057   Q_OBJECT
00058 
00059   public:
00060     KateScrollBar(Qt::Orientation orientation, class KateViewInternal *parent);
00061 
00062     inline bool showMarks() { return m_showMarks; }
00063     inline void setShowMarks(bool b) { m_showMarks = b; update(); }
00064 
00065   Q_SIGNALS:
00066     void sliderMMBMoved(int value);
00067 
00068   protected:
00069     virtual void mousePressEvent(QMouseEvent* e);
00070     virtual void mouseReleaseEvent(QMouseEvent* e);
00071     virtual void mouseMoveEvent (QMouseEvent* e);
00072     virtual void paintEvent(QPaintEvent *);
00073     virtual void resizeEvent(QResizeEvent *);
00074     virtual void styleChange(QStyle &oldStyle);
00075     virtual void sliderChange ( SliderChange change );
00076 
00077   protected Q_SLOTS:
00078     void sliderMaybeMoved(int value);
00079     void marksChanged();
00080 
00081   private:
00082     void redrawMarks();
00083     void recomputeMarksPositions();
00084 
00085     bool m_middleMouseDown;
00086 
00087     KateView *m_view;
00088     KateDocument *m_doc;
00089     class KateViewInternal *m_viewInternal;
00090 
00091     int m_topMargin;
00092     int m_bottomMargin;
00093     int m_savVisibleLines;
00094 
00095     QHash<int, QColor> m_lines;
00096 
00097     bool m_showMarks;
00098 };
00099 
00100 class KateIconBorder : public QWidget
00101 {
00102   Q_OBJECT
00103 
00104   public:
00105     KateIconBorder( KateViewInternal* internalView, QWidget *parent );
00106     virtual ~KateIconBorder();
00107     // VERY IMPORTANT ;)
00108     virtual QSize sizeHint() const;
00109 
00110     void updateFont();
00111     int lineNumberWidth() const;
00112 
00113     void setIconBorderOn(       bool enable );
00114     void setLineNumbersOn(      bool enable );
00115     void setAnnotationBorderOn( bool enable );
00116     void setDynWrapIndicators(int state );
00117     int dynWrapIndicators()  const { return m_dynWrapIndicators; }
00118     bool dynWrapIndicatorsOn() const { return m_dynWrapIndicatorsOn; }
00119     void setFoldingMarkersOn( bool enable );
00120     void toggleIconBorder()     { setIconBorderOn(     !iconBorderOn() );     }
00121     void toggleLineNumbers()    { setLineNumbersOn(    !lineNumbersOn() );    }
00122     void toggleFoldingMarkers() { setFoldingMarkersOn( !foldingMarkersOn() ); }
00123     inline bool iconBorderOn()       const { return m_iconBorderOn;       }
00124     inline bool lineNumbersOn()      const { return m_lineNumbersOn;      }
00125     inline bool foldingMarkersOn()   const { return m_foldingMarkersOn;   }
00126     inline bool annotationBorderOn() const { return m_annotationBorderOn; }
00127 
00128     enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers, AnnotationBorder };
00129     BorderArea positionToArea( const QPoint& ) const;
00130 
00131   Q_SIGNALS:
00132     void toggleRegionVisibility( unsigned int );
00133   public Q_SLOTS:
00134     void updateAnnotationBorderWidth();
00135     void updateAnnotationLine( int line );
00136     void annotationModelChanged( KTextEditor::AnnotationModel* oldmodel, KTextEditor::AnnotationModel* newmodel );
00137 
00138   private:
00139     void paintEvent( QPaintEvent* );
00140     void paintBorder (int x, int y, int width, int height);
00141 
00142     void mousePressEvent( QMouseEvent* );
00143     void mouseMoveEvent( QMouseEvent* );
00144     void mouseReleaseEvent( QMouseEvent* );
00145     void mouseDoubleClickEvent( QMouseEvent* );
00146     void leaveEvent(QEvent *event);
00147 
00148     void showMarkMenu( uint line, const QPoint& pos );
00149 
00150     void showAnnotationTooltip( int line, const QPoint& pos );
00151     void hideAnnotationTooltip();
00152     void removeAnnotationHovering();
00153     void showAnnotationMenu( int line, const QPoint& pos);
00154     int annotationLineWidth( int line );
00155 
00156     KateView *m_view;
00157     KateDocument *m_doc;
00158     KateViewInternal *m_viewInternal;
00159 
00160     bool m_iconBorderOn:1;
00161     bool m_lineNumbersOn:1;
00162     bool m_foldingMarkersOn:1;
00163     bool m_dynWrapIndicatorsOn:1;
00164     bool m_annotationBorderOn:1;
00165     int m_dynWrapIndicators;
00166 
00167     int m_lastClickedLine;
00168 
00169     int m_cachedLNWidth;
00170 
00171     int m_maxCharWidth;
00172     int iconPaneWidth;
00173     int m_annotationBorderWidth;
00174 
00175     mutable QPixmap m_arrow;
00176     mutable QColor m_oldBackgroundColor;
00177 
00178     KTextEditor::SmartRange *m_foldingRange;
00179     int m_lastBlockLine;
00180     void showBlock(int line);
00181     void hideBlock();
00182 
00183     QBrush m_foldingColors[MAXFOLDINGCOLORS];
00184     QBrush m_foldingColorsSolid[MAXFOLDINGCOLORS];
00185     const QBrush &foldingColor(KateLineInfo *, int,bool solid);
00186     QString m_hoveredAnnotationText;
00187 };
00188 
00189 class KateViewEncodingAction : public KCodecAction
00190 {
00191   Q_OBJECT
00192 
00193   public:
00194     KateViewEncodingAction(KateDocument *_doc, KateView *_view, const QString& text, QObject *parent);
00195 
00196     ~KateViewEncodingAction(){}
00197 
00198   private:
00199     KateDocument* doc;
00200     KateView *view;
00201 
00202   private Q_SLOTS:
00203     void setEncoding (const QString &e);
00204     void setScriptForEncodingAutoDetection (KEncodingDetector::AutoDetectScript);
00205     void slotAboutToShow();
00206 };
00207 
00208 class KateViewBar;
00209 
00210 class KateViewBarWidget : public QWidget
00211 {
00212   Q_OBJECT
00213 
00214   public:
00215     KateViewBarWidget (KateViewBar *viewBar);
00216 
00217     KateViewBar *viewBar () { return m_viewBar; }
00218     QWidget *centralWidget () { return m_centralWidget; }
00219 
00220   public Q_SLOTS:
00221     void showBar ();
00222     void hideBar ();
00223 
00224   protected:
00225     // allow subclass to avoid hiding...
00226     virtual bool hideIsTriggered () { return true; }
00227 
00228   private:
00229     KateViewBar *m_viewBar;
00230     QWidget *m_centralWidget;
00231 };
00232 
00233 // Helper layout class to always provide minimum size
00234 class KateStackedLayout : public QStackedLayout
00235 {
00236   Q_OBJECT
00237 public:
00238   KateStackedLayout(QWidget* parent);
00239   virtual QSize sizeHint() const;
00240   virtual QSize minimumSize() const;
00241 };
00242 
00243 class KateViewBar : public QWidget
00244 {
00245   Q_OBJECT
00246 
00247   friend class KateViewBarWidget;
00248 
00249   public:
00250     KateViewBar (KateView *view);
00251 
00252     KateView *view () { return m_view; }
00253 
00254   protected:
00255     virtual void keyPressEvent(QKeyEvent* event);
00256     virtual void hideEvent(QHideEvent* event);
00257 
00258   private:
00259     void addBarWidget (KateViewBarWidget *newBarWidget);
00260     void showBarWidget (KateViewBarWidget *barWidget);
00261     void hideBarWidget ();
00262 
00263   private:
00264     KateView *m_view;
00265     KateStackedLayout *m_stack;
00266 };
00267 
00268 class KateCmdLine : public KateViewBarWidget
00269 {
00270   public:
00271     explicit KateCmdLine(KateView *view, KateViewBar *viewBar);
00272     ~KateCmdLine();
00273 
00274   private:
00275     class KateCmdLineEdit *m_lineEdit;
00276 };
00277 
00278 class KateCmdLineEdit : public KLineEdit
00279 {
00280   Q_OBJECT
00281 
00282   public:
00283     KateCmdLineEdit (KateCmdLine *bar, KateView *view);
00284     virtual bool event(QEvent *e);
00285   private Q_SLOTS:
00286     void slotReturnPressed ( const QString& cmd );
00287     void hideBar ();
00288 
00289   protected:
00290     void focusInEvent ( QFocusEvent *ev );
00291     void keyPressEvent( QKeyEvent *ev );
00292 
00293   private:
00294     void fromHistory( bool up );
00295     QString helptext( const QPoint & ) const;
00296 
00297     KateView *m_view;
00298     KateCmdLine *m_bar;
00299     bool m_msgMode;
00300     QString m_oldText;
00301     uint m_histpos; 
00302     uint m_cmdend; 
00303     KTextEditor::Command *m_command; 
00304     class KCompletion *m_oldCompletionObject; 
00305     class KateCmdLnWhatsThis *m_help;
00306 };
00307 
00308 #endif
00309 
00310 // 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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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