kateviewhelpers.h
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 <tdeaction.h> 00025 #include <klineedit.h> 00026 00027 #include <tqwidget.h> 00028 #include <tqpixmap.h> 00029 #include <tqcolor.h> 00030 #include <tqscrollbar.h> 00031 #include <tqintdict.h> 00032 00033 class KateDocument; 00034 class KateView; 00035 class KateViewInternal; 00036 00037 namespace Kate { 00038 class Command; 00039 } 00040 00048 class KateScrollBar : public TQScrollBar 00049 { 00050 Q_OBJECT 00051 00052 public: 00053 KateScrollBar(Orientation orientation, class KateViewInternal *parent, const char* name = 0L); 00054 00055 inline bool showMarks() { return m_showMarks; }; 00056 inline void setShowMarks(bool b) { m_showMarks = b; update(); }; 00057 00058 signals: 00059 void sliderMMBMoved(int value); 00060 00061 protected: 00062 virtual void mousePressEvent(TQMouseEvent* e); 00063 virtual void mouseReleaseEvent(TQMouseEvent* e); 00064 virtual void mouseMoveEvent (TQMouseEvent* e); 00065 virtual void paintEvent(TQPaintEvent *); 00066 virtual void resizeEvent(TQResizeEvent *); 00067 virtual void styleChange(TQStyle &oldStyle); 00068 virtual void valueChange(); 00069 virtual void rangeChange(); 00070 00071 protected slots: 00072 void sliderMaybeMoved(int value); 00073 void marksChanged(); 00074 00075 private: 00076 void redrawMarks(); 00077 void recomputeMarksPositions(bool forceFullUpdate = false); 00078 void watchScrollBarSize(); 00079 00080 bool m_middleMouseDown; 00081 00082 KateView *m_view; 00083 KateDocument *m_doc; 00084 class KateViewInternal *m_viewInternal; 00085 00086 int m_topMargin; 00087 int m_bottomMargin; 00088 uint m_savVisibleLines; 00089 00090 TQIntDict<TQColor> m_lines; 00091 00092 bool m_showMarks; 00093 }; 00094 00095 class KateCmdLine : public KLineEdit 00096 { 00097 Q_OBJECT 00098 00099 public: 00100 KateCmdLine (KateView *view); 00101 00102 private slots: 00103 void slotReturnPressed ( const TQString& cmd ); 00104 void hideMe (); 00105 00106 protected: 00107 void focusInEvent ( TQFocusEvent *ev ); 00108 void keyPressEvent( TQKeyEvent *ev ); 00109 00110 private: 00111 void fromHistory( bool up ); 00112 KateView *m_view; 00113 bool m_msgMode; 00114 TQString m_oldText; 00115 uint m_histpos; 00116 uint m_cmdend; 00117 Kate::Command *m_command; 00118 class TDECompletion *m_oldCompletionObject; 00119 class KateCmdLnWhatsThis *m_help; 00120 }; 00121 00122 class KateIconBorder : public TQWidget 00123 { 00124 Q_OBJECT 00125 00126 public: 00127 KateIconBorder( KateViewInternal* internalView, TQWidget *parent ); 00128 00129 // VERY IMPORTANT ;) 00130 virtual TQSize sizeHint() const; 00131 00132 void updateFont(); 00133 int lineNumberWidth() const; 00134 00135 void setIconBorderOn( bool enable ); 00136 void setLineNumbersOn( bool enable ); 00137 void setDynWrapIndicators(int state ); 00138 int dynWrapIndicators() const { return m_dynWrapIndicators; } 00139 bool dynWrapIndicatorsOn() const { return m_dynWrapIndicatorsOn; } 00140 void setFoldingMarkersOn( bool enable ); 00141 void toggleIconBorder() { setIconBorderOn( !iconBorderOn() ); } 00142 void toggleLineNumbers() { setLineNumbersOn( !lineNumbersOn() ); } 00143 void toggleFoldingMarkers() { setFoldingMarkersOn( !foldingMarkersOn() ); } 00144 bool iconBorderOn() const { return m_iconBorderOn; } 00145 bool lineNumbersOn() const { return m_lineNumbersOn; } 00146 bool foldingMarkersOn() const { return m_foldingMarkersOn; } 00147 00148 enum BorderArea { None, LineNumbers, IconBorder, FoldingMarkers }; 00149 BorderArea positionToArea( const TQPoint& ) const; 00150 00151 signals: 00152 void toggleRegionVisibility( unsigned int ); 00153 00154 private: 00155 void paintEvent( TQPaintEvent* ); 00156 void paintBorder (int x, int y, int width, int height); 00157 00158 void mousePressEvent( TQMouseEvent* ); 00159 void mouseMoveEvent( TQMouseEvent* ); 00160 void mouseReleaseEvent( TQMouseEvent* ); 00161 void mouseDoubleClickEvent( TQMouseEvent* ); 00162 00163 void showMarkMenu( uint line, const TQPoint& pos ); 00164 00165 KateView *m_view; 00166 KateDocument *m_doc; 00167 KateViewInternal *m_viewInternal; 00168 00169 bool m_iconBorderOn:1; 00170 bool m_lineNumbersOn:1; 00171 bool m_foldingMarkersOn:1; 00172 bool m_dynWrapIndicatorsOn:1; 00173 int m_dynWrapIndicators; 00174 00175 uint m_lastClickedLine; 00176 00177 int m_cachedLNWidth; 00178 00179 int m_maxCharWidth; 00180 00181 mutable TQPixmap m_arrow; 00182 mutable TQColor m_oldBackgroundColor; 00183 }; 00184 00185 class KateViewEncodingAction : public TDEActionMenu 00186 { 00187 Q_OBJECT 00188 00189 public: 00190 KateViewEncodingAction(KateDocument *_doc, KateView *_view, const TQString& text, TQObject* parent = 0, const char* name = 0); 00191 00192 ~KateViewEncodingAction(){;}; 00193 00194 private: 00195 KateDocument* doc; 00196 KateView *view; 00197 00198 public slots: 00199 void slotAboutToShow(); 00200 00201 private slots: 00202 void setMode (int mode); 00203 }; 00204 00205 #endif 00206 00207 // kate: space-indent on; indent-width 2; replace-tabs on;