~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/plugins/grass/qtermwidget/TerminalDisplay.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>
 
3
    Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
 
4
 
 
5
    Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
 
6
 
 
7
    This program is free software; you can redistribute it and/or modify
 
8
    it under the terms of the GNU General Public License as published by
 
9
    the Free Software Foundation; either version 2 of the License, or
 
10
    (at your option) any later version.
 
11
 
 
12
    This program is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU General Public License
 
18
    along with this program; if not, write to the Free Software
 
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
20
    02110-1301  USA.
 
21
*/
 
22
 
 
23
#ifndef TERMINALDISPLAY_H
 
24
#define TERMINALDISPLAY_H
 
25
 
 
26
// Qt
 
27
#include <QtGui/QColor>
 
28
#include <QtCore/QPointer>
 
29
#include <QtGui/QWidget>
 
30
 
 
31
// Konsole
 
32
#include "Filter.h"
 
33
#include "Character.h"
 
34
#include "ColorTables.h"
 
35
 
 
36
class QDrag;
 
37
class QDragEnterEvent;
 
38
class QDropEvent;
 
39
class QLabel;
 
40
class QTimer;
 
41
class QEvent;
 
42
class QFrame;
 
43
class QGridLayout;
 
44
class QKeyEvent;
 
45
class QScrollBar;
 
46
class QShowEvent;
 
47
class QHideEvent;
 
48
class QWidget;
 
49
 
 
50
//class KMenu;
 
51
 
 
52
namespace Konsole
 
53
{
 
54
 
 
55
  extern unsigned short vt100_graphics[32];
 
56
 
 
57
  class ScreenWindow;
 
58
 
 
59
  /**
 
60
   * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity
 
61
   * to the terminal.
 
62
   *
 
63
   * When the terminal emulation receives new output from the program running in the terminal,
 
64
   * it will update the display by calling updateImage().
 
65
   *
 
66
   * TODO More documentation
 
67
   */
 
68
  class TerminalDisplay : public QWidget
 
69
  {
 
70
      Q_OBJECT
 
71
 
 
72
    public:
 
73
      /** Constructs a new terminal display widget with the specified parent. */
 
74
      TerminalDisplay( QWidget *parent = 0 );
 
75
      virtual ~TerminalDisplay();
 
76
 
 
77
      /** Returns the terminal color palette used by the display. */
 
78
      const ColorEntry* colorTable() const;
 
79
      /** Sets the terminal color palette used by the display. */
 
80
      void setColorTable( const ColorEntry table[] );
 
81
      /**
 
82
       * Sets the seed used to generate random colors for the display
 
83
       * (in color schemes that support them).
 
84
       */
 
85
      void setRandomSeed( uint seed );
 
86
      /**
 
87
       * Returns the seed used to generate random colors for the display
 
88
       * (in color schemes that support them).
 
89
       */
 
90
      uint randomSeed() const;
 
91
 
 
92
      /** Sets the opacity of the terminal display. */
 
93
      void setOpacity( qreal opacity );
 
94
 
 
95
      /**
 
96
       * This enum describes the location where the scroll bar is positioned in the display widget.
 
97
       */
 
98
      enum ScrollBarPosition
 
99
      {
 
100
        /** Do not show the scroll bar. */
 
101
        NoScrollBar = 0,
 
102
        /** Show the scroll bar on the left side of the display. */
 
103
        ScrollBarLeft = 1,
 
104
        /** Show the scroll bar on the right side of the display. */
 
105
        ScrollBarRight = 2
 
106
      };
 
107
      /**
 
108
       * Specifies whether the terminal display has a vertical scroll bar, and if so whether it
 
109
       * is shown on the left or right side of the display.
 
110
       */
 
111
      void setScrollBarPosition( ScrollBarPosition position );
 
112
 
 
113
      /**
 
114
       * Sets the current position and range of the display's scroll bar.
 
115
       *
 
116
       * @param cursor The position of the scroll bar's thumb.
 
117
       * @param lines The maximum value of the scroll bar.
 
118
       */
 
119
      void setScroll( int cursor, int lines );
 
120
 
 
121
      /**
 
122
       * Returns the display's filter chain.  When the image for the display is updated,
 
123
       * the text is passed through each filter in the chain.  Each filter can define
 
124
       * hotspots which correspond to certain strings (such as URLs or particular words).
 
125
       * Depending on the type of the hotspots created by the filter ( returned by Filter::Hotspot::type() )
 
126
       * the view will draw visual cues such as underlines on mouse-over for links or translucent
 
127
       * rectangles for markers.
 
128
       *
 
129
       * To add a new filter to the view, call:
 
130
       *      viewWidget->filterChain()->addFilter( filterObject );
 
131
       */
 
132
      FilterChain* filterChain() const;
 
133
 
 
134
      /**
 
135
       * Updates the filters in the display's filter chain.  This will cause
 
136
       * the hotspots to be updated to match the current image.
 
137
       *
 
138
       * WARNING:  This function can be expensive depending on the
 
139
       * image size and number of filters in the filterChain()
 
140
       *
 
141
       * TODO - This API does not really allow efficient usage.  Revise it so
 
142
       * that the processing can be done in a better way.
 
143
       *
 
144
       * eg:
 
145
       *      - Area of interest may be known ( eg. mouse cursor hovering
 
146
       *      over an area )
 
147
       */
 
148
      void processFilters();
 
149
 
 
150
      /**
 
151
       * Returns a list of menu actions created by the filters for the content
 
152
       * at the given @p position.
 
153
       */
 
154
      QList<QAction*> filterActions( const QPoint& position );
 
155
 
 
156
      /** Returns true if the cursor is set to blink or false otherwise. */
 
157
      bool blinkingCursor() { return _hasBlinkingCursor; }
 
158
      /** Specifies whether or not the cursor blinks. */
 
159
      void setBlinkingCursor( bool blink );
 
160
 
 
161
      void setCtrlDrag( bool enable ) { _ctrlDrag = enable; }
 
162
      bool ctrlDrag() { return _ctrlDrag; }
 
163
 
 
164
      /**
 
165
         *  This enum describes the methods for selecting text when
 
166
       *  the user triple-clicks within the display.
 
167
       */
 
168
      enum TripleClickMode
 
169
      {
 
170
        /** Select the whole line underneath the cursor. */
 
171
        SelectWholeLine,
 
172
        /** Select from the current cursor position to the end of the line. */
 
173
        SelectForwardsFromCursor
 
174
      };
 
175
      /** Sets how the text is selected when the user triple clicks within the display. */
 
176
      void setTripleClickMode( TripleClickMode mode ) { _tripleClickMode = mode; }
 
177
      /** See setTripleClickSelectionMode() */
 
178
      TripleClickMode tripleClickMode() { return _tripleClickMode; }
 
179
 
 
180
      void setLineSpacing( uint );
 
181
      uint lineSpacing() const;
 
182
 
 
183
      void emitSelection( bool useXselection, bool appendReturn );
 
184
 
 
185
      /**
 
186
       * This enum describes the available shapes for the keyboard cursor.
 
187
       * See setKeyboardCursorShape()
 
188
       */
 
189
      enum KeyboardCursorShape
 
190
      {
 
191
        /** A rectangular block which covers the entire area of the cursor character. */
 
192
        BlockCursor,
 
193
        /**
 
194
         * A single flat line which occupies the space at the bottom of the cursor
 
195
         * character's area.
 
196
         */
 
197
        UnderlineCursor,
 
198
        /**
 
199
         * An cursor shaped like the capital letter 'I', similar to the IBeam
 
200
         * cursor used in Qt/KDE text editors.
 
201
         */
 
202
        IBeamCursor
 
203
      };
 
204
      /**
 
205
       * Sets the shape of the keyboard cursor.  This is the cursor drawn
 
206
       * at the position in the terminal where keyboard input will appear.
 
207
       *
 
208
       * In addition the terminal display widget also has a cursor for
 
209
       * the mouse pointer, which can be set using the QWidget::setCursor()
 
210
       * method.
 
211
       *
 
212
       * Defaults to BlockCursor
 
213
       */
 
214
      void setKeyboardCursorShape( KeyboardCursorShape shape );
 
215
      /**
 
216
       * Returns the shape of the keyboard cursor.  See setKeyboardCursorShape()
 
217
       */
 
218
      KeyboardCursorShape keyboardCursorShape() const;
 
219
 
 
220
      /**
 
221
       * Sets the color used to draw the keyboard cursor.
 
222
       *
 
223
       * The keyboard cursor defaults to using the foreground color of the character
 
224
       * underneath it.
 
225
       *
 
226
       * @param useForegroundColor If true, the cursor color will change to match
 
227
       * the foreground color of the character underneath it as it is moved, in this
 
228
       * case, the @p color parameter is ignored and the color of the character
 
229
       * under the cursor is inverted to ensure that it is still readable.
 
230
       * @param color The color to use to draw the cursor.  This is only taken into
 
231
       * account if @p useForegroundColor is false.
 
232
       */
 
233
      void setKeyboardCursorColor( bool useForegroundColor , const QColor& color );
 
234
 
 
235
      /**
 
236
       * Returns the color of the keyboard cursor, or an invalid color if the keyboard
 
237
       * cursor color is set to change according to the foreground color of the character
 
238
       * underneath it.
 
239
       */
 
240
      QColor keyboardCursorColor() const;
 
241
 
 
242
      /**
 
243
       * Returns the number of lines of text which can be displayed in the widget.
 
244
       *
 
245
       * This will depend upon the height of the widget and the current font.
 
246
       * See fontHeight()
 
247
       */
 
248
      int  lines()   { return _lines;   }
 
249
      /**
 
250
       * Returns the number of characters of text which can be displayed on
 
251
       * each line in the widget.
 
252
       *
 
253
       * This will depend upon the width of the widget and the current font.
 
254
       * See fontWidth()
 
255
       */
 
256
      int  columns() { return _columns; }
 
257
 
 
258
      /**
 
259
       * Returns the height of the characters in the font used to draw the text in the display.
 
260
       */
 
261
      int  fontHeight()   { return _fontHeight;   }
 
262
      /**
 
263
       * Returns the width of the characters in the display.
 
264
       * This assumes the use of a fixed-width font.
 
265
       */
 
266
      int  fontWidth()    { return _fontWidth; }
 
267
 
 
268
      void setSize( int cols, int lins );
 
269
      void setFixedSize( int cols, int lins );
 
270
 
 
271
      // reimplemented
 
272
      QSize sizeHint() const;
 
273
 
 
274
      /**
 
275
       * Sets which characters, in addition to letters and numbers,
 
276
       * are regarded as being part of a word for the purposes
 
277
       * of selecting words in the display by double clicking on them.
 
278
       *
 
279
       * The word boundaries occur at the first and last characters which
 
280
       * are either a letter, number, or a character in @p wc
 
281
       *
 
282
       * @param wc An array of characters which are to be considered parts
 
283
       * of a word ( in addition to letters and numbers ).
 
284
       */
 
285
      void setWordCharacters( const QString& wc );
 
286
      /**
 
287
       * Returns the characters which are considered part of a word for the
 
288
       * purpose of selecting words in the display with the mouse.
 
289
       *
 
290
       * @see setWordCharacters()
 
291
       */
 
292
      QString wordCharacters() { return _wordCharacters; }
 
293
 
 
294
      /**
 
295
       * Sets the type of effect used to alert the user when a 'bell' occurs in the
 
296
       * terminal session.
 
297
       *
 
298
       * The terminal session can trigger the bell effect by calling bell() with
 
299
       * the alert message.
 
300
       */
 
301
      void setBellMode( int mode );
 
302
      /**
 
303
       * Returns the type of effect used to alert the user when a 'bell' occurs in
 
304
       * the terminal session.
 
305
       *
 
306
       * See setBellMode()
 
307
       */
 
308
      int bellMode() { return _bellMode; }
 
309
 
 
310
      /**
 
311
       * This enum describes the different types of sounds and visual effects which
 
312
       * can be used to alert the user when a 'bell' occurs in the terminal
 
313
       * session.
 
314
       */
 
315
      enum BellMode
 
316
      {
 
317
        /** A system beep. */
 
318
        SystemBeepBell = 0,
 
319
        /**
 
320
         * KDE notification.  This may play a sound, show a passive popup
 
321
         * or perform some other action depending on the user's settings.
 
322
         */
 
323
        NotifyBell = 1,
 
324
        /** A silent, visual bell (eg. inverting the display's colors briefly) */
 
325
        VisualBell = 2,
 
326
        /** No bell effects */
 
327
        NoBell = 3
 
328
      };
 
329
 
 
330
      void setSelection( const QString &t );
 
331
 
 
332
      /**
 
333
       * Reimplemented.  Has no effect.  Use setVTFont() to change the font
 
334
       * used to draw characters in the display.
 
335
       */
 
336
      virtual void setFont( const QFont & );
 
337
 
 
338
      /** Returns the font used to draw characters in the display */
 
339
      QFont getVTFont() { return font(); }
 
340
 
 
341
      /**
 
342
       * Sets the font used to draw the display.  Has no effect if @p font
 
343
       * is larger than the size of the display itself.
 
344
       */
 
345
      void setVTFont( const QFont& font );
 
346
 
 
347
      /**
 
348
       * Specified whether anti-aliasing of text in the terminal display
 
349
       * is enabled or not.  Defaults to enabled.
 
350
       */
 
351
      static void setAntialias( bool antialias ) { _antialiasText = antialias; }
 
352
      /**
 
353
       * Returns true if anti-aliasing of text in the terminal is enabled.
 
354
       */
 
355
      static bool antialias()                 { return _antialiasText;   }
 
356
 
 
357
      /**
 
358
       * Sets whether or not the current height and width of the
 
359
       * terminal in lines and columns is displayed whilst the widget
 
360
       * is being resized.
 
361
       */
 
362
      void setTerminalSizeHint( bool on ) { _terminalSizeHint = on; }
 
363
      /**
 
364
       * Returns whether or not the current height and width of
 
365
       * the terminal in lines and columns is displayed whilst the widget
 
366
       * is being resized.
 
367
       */
 
368
      bool terminalSizeHint() { return _terminalSizeHint; }
 
369
      /**
 
370
       * Sets whether the terminal size display is shown briefly
 
371
       * after the widget is first shown.
 
372
       *
 
373
       * See setTerminalSizeHint() , isTerminalSizeHint()
 
374
       */
 
375
      void setTerminalSizeStartup( bool on ) { _terminalSizeStartup = on; }
 
376
 
 
377
      void setBidiEnabled( bool set ) { _bidiEnabled = set; }
 
378
      bool isBidiEnabled() { return _bidiEnabled; }
 
379
 
 
380
      /**
 
381
       * Sets the terminal screen section which is displayed in this widget.
 
382
       * When updateImage() is called, the display fetches the latest character image from the
 
383
       * the associated terminal screen window.
 
384
       *
 
385
       * In terms of the model-view paradigm, the ScreenWindow is the model which is rendered
 
386
       * by the TerminalDisplay.
 
387
       */
 
388
      void setScreenWindow( ScreenWindow* window );
 
389
      /** Returns the terminal screen section which is displayed in this widget.  See setScreenWindow() */
 
390
      ScreenWindow* screenWindow() const;
 
391
 
 
392
      static bool HAVE_TRANSPARENCY;
 
393
 
 
394
    public slots:
 
395
 
 
396
      /**
 
397
       * Causes the terminal display to fetch the latest character image from the associated
 
398
       * terminal screen ( see setScreenWindow() ) and redraw the display.
 
399
       */
 
400
      void updateImage();
 
401
      /**
 
402
       * Causes the terminal display to fetch the latest line status flags from the
 
403
       * associated terminal screen ( see setScreenWindow() ).
 
404
       */
 
405
      void updateLineProperties();
 
406
 
 
407
      /** Copies the selected text to the clipboard. */
 
408
      void copyClipboard();
 
409
      /**
 
410
       * Pastes the content of the clipboard into the
 
411
       * display.
 
412
       */
 
413
      void pasteClipboard();
 
414
      /**
 
415
       * Pastes the content of the selection into the
 
416
       * display.
 
417
       */
 
418
      void pasteSelection();
 
419
 
 
420
      /**
 
421
        * Changes whether the flow control warning box should be shown when the flow control
 
422
        * stop key (Ctrl+S) are pressed.
 
423
        */
 
424
      void setFlowControlWarningEnabled( bool enabled );
 
425
 
 
426
      /**
 
427
      * Causes the widget to display or hide a message informing the user that terminal
 
428
      * output has been suspended (by using the flow control key combination Ctrl+S)
 
429
      *
 
430
      * @param suspended True if terminal output has been suspended and the warning message should
 
431
      *          be shown or false to indicate that terminal output has been resumed and that
 
432
      *          the warning message should disappear.
 
433
      */
 
434
      void outputSuspended( bool suspended );
 
435
 
 
436
      /**
 
437
       * Sets whether the program whoose output is being displayed in the view
 
438
       * is interested in mouse events.
 
439
       *
 
440
       * If this is set to true, mouse signals will be emitted by the view when the user clicks, drags
 
441
       * or otherwise moves the mouse inside the view.
 
442
       * The user interaction needed to create selections will also change, and the user will be required
 
443
       * to hold down the shift key to create a selection or perform other mouse activities inside the
 
444
       * view area - since the program running in the terminal is being allowed to handle normal mouse
 
445
       * events itself.
 
446
       *
 
447
       * @param usesMouse Set to true if the program running in the terminal is interested in mouse events
 
448
       * or false otherwise.
 
449
       */
 
450
      void setUsesMouse( bool usesMouse );
 
451
 
 
452
      /** See setUsesMouse() */
 
453
      bool usesMouse() const;
 
454
 
 
455
      /**
 
456
       * Shows a notification that a bell event has occurred in the terminal.
 
457
       * TODO: More documentation here
 
458
       */
 
459
      void bell( const QString& message );
 
460
 
 
461
    signals:
 
462
 
 
463
      /**
 
464
       * Emitted when the user presses a key whilst the terminal widget has focus.
 
465
       */
 
466
      void keyPressedSignal( QKeyEvent *e );
 
467
 
 
468
      /**
 
469
       * Emitted when the user presses the suspend or resume flow control key combinations
 
470
       *
 
471
       * @param suspend true if the user pressed Ctrl+S (the suspend output key combination) or
 
472
       * false if the user pressed Ctrl+Q (the resume output key combination)
 
473
       */
 
474
      void flowControlKeyPressed( bool suspend );
 
475
 
 
476
      /**
 
477
       * A mouse event occurred.
 
478
       * @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release)
 
479
       * @param column The character column where the event occurred
 
480
       * @param line The character row where the event occurred
 
481
       * @param eventType The type of event.  0 for a mouse press / release or 1 for mouse motion
 
482
       */
 
483
      void mouseSignal( int button, int column, int line, int eventType );
 
484
      void changedFontMetricSignal( int height, int width );
 
485
      void changedContentSizeSignal( int height, int width );
 
486
 
 
487
      /**
 
488
       * Emitted when the user right clicks on the display, or right-clicks with the Shift
 
489
       * key held down if usesMouse() is true.
 
490
       *
 
491
       * This can be used to display a context menu.
 
492
       */
 
493
      void configureRequest( TerminalDisplay*, int state, const QPoint& position );
 
494
 
 
495
      void isBusySelecting( bool );
 
496
      void sendStringToEmu( const char* );
 
497
 
 
498
    protected:
 
499
      virtual bool event( QEvent * );
 
500
 
 
501
      virtual void paintEvent( QPaintEvent * );
 
502
 
 
503
      virtual void showEvent( QShowEvent* );
 
504
      virtual void hideEvent( QHideEvent* );
 
505
      virtual void resizeEvent( QResizeEvent* );
 
506
 
 
507
      virtual void fontChange( const QFont &font );
 
508
 
 
509
      virtual void keyPressEvent( QKeyEvent* event );
 
510
      virtual void mouseDoubleClickEvent( QMouseEvent* ev );
 
511
      virtual void mousePressEvent( QMouseEvent* );
 
512
      virtual void mouseReleaseEvent( QMouseEvent* );
 
513
      virtual void mouseMoveEvent( QMouseEvent* );
 
514
      virtual void extendSelection( const QPoint& pos );
 
515
      virtual void wheelEvent( QWheelEvent* );
 
516
 
 
517
      virtual bool focusNextPrevChild( bool next );
 
518
 
 
519
      // drag and drop
 
520
      virtual void dragEnterEvent( QDragEnterEvent* event );
 
521
      virtual void dropEvent( QDropEvent* event );
 
522
      void doDrag();
 
523
      enum DragState { diNone, diPending, diDragging };
 
524
 
 
525
      struct _dragInfo
 
526
      {
 
527
        DragState       state;
 
528
        QPoint          start;
 
529
        QDrag           *dragObject;
 
530
      } dragInfo;
 
531
 
 
532
      virtual int charClass( quint16 ) const;
 
533
 
 
534
      void clearImage();
 
535
 
 
536
      void mouseTripleClickEvent( QMouseEvent* ev );
 
537
 
 
538
      // reimplemented
 
539
      virtual void inputMethodEvent( QInputMethodEvent* event );
 
540
      virtual QVariant inputMethodQuery( Qt::InputMethodQuery query ) const;
 
541
 
 
542
    protected slots:
 
543
 
 
544
      void scrollBarPositionChanged( int value );
 
545
      void blinkEvent();
 
546
      void blinkCursorEvent();
 
547
 
 
548
      //Renables bell noises and visuals.  Used to disable further bells for a short period of time
 
549
      //after emitting the first in a sequence of bell events.
 
550
      void enableBell();
 
551
 
 
552
    private slots:
 
553
 
 
554
      void swapColorTable();
 
555
      void tripleClickTimeout();  // resets possibleTripleClick
 
556
 
 
557
    private:
 
558
 
 
559
      // -- Drawing helpers --
 
560
 
 
561
      // divides the part of the display specified by 'rect' into
 
562
      // fragments according to their colors and styles and calls
 
563
      // drawTextFragment() to draw the fragments
 
564
      void drawContents( QPainter &paint, const QRect &rect );
 
565
      // draws a section of text, all the text in this section
 
566
      // has a common color and style
 
567
      void drawTextFragment( QPainter& painter, const QRect& rect,
 
568
                             const QString& text, const Character* style );
 
569
      // draws the background for a text fragment
 
570
      // if useOpacitySetting is true then the color's alpha value will be set to
 
571
      // the display's transparency (set with setOpacity()), otherwise the background
 
572
      // will be drawn fully opaque
 
573
      void drawBackground( QPainter& painter, const QRect& rect, const QColor& color,
 
574
                           bool useOpacitySetting );
 
575
      // draws the cursor character
 
576
      void drawCursor( QPainter& painter, const QRect& rect , const QColor& foregroundColor,
 
577
                       const QColor& backgroundColor , bool& invertColors );
 
578
      // draws the characters or line graphics in a text fragment
 
579
      void drawCharacters( QPainter& painter, const QRect& rect,  const QString& text,
 
580
                           const Character* style, bool invertCharacterColor );
 
581
      // draws a string of line graphics
 
582
      void drawLineCharString( QPainter& painter, int x, int y,
 
583
                               const QString& str, const Character* attributes );
 
584
 
 
585
      // draws the preedit string for input methods
 
586
      void drawInputMethodPreeditString( QPainter& painter , const QRect& rect );
 
587
 
 
588
      // --
 
589
 
 
590
      // maps an area in the character image to an area on the widget
 
591
      QRect imageToWidget( const QRect& imageArea ) const;
 
592
 
 
593
      // maps a point on the widget to the position ( ie. line and column )
 
594
      // of the character at that point.
 
595
      void getCharacterPosition( const QPoint& widgetPoint, int& line, int& column ) const;
 
596
 
 
597
      // the area where the preedit string for input methods will be draw
 
598
      QRect preeditRect() const;
 
599
 
 
600
      // shows a notification window in the middle of the widget indicating the terminal's
 
601
      // current size in columns and lines
 
602
      void showResizeNotification();
 
603
 
 
604
      // scrolls the image by a number of lines.
 
605
      // 'lines' may be positive ( to scroll the image down )
 
606
      // or negative ( to scroll the image up )
 
607
      // 'region' is the part of the image to scroll - currently only
 
608
      // the top, bottom and height of 'region' are taken into account,
 
609
      // the left and right are ignored.
 
610
      void scrollImage( int lines , const QRect& region );
 
611
 
 
612
      void calcGeometry();
 
613
      void propagateSize();
 
614
      void updateImageSize();
 
615
      void makeImage();
 
616
 
 
617
      void paintFilters( QPainter& painter );
 
618
 
 
619
      // returns a region covering all of the areas of the widget which contain
 
620
      // a hotspot
 
621
      QRegion hotSpotRegion() const;
 
622
 
 
623
      // returns the position of the cursor in columns and lines
 
624
      QPoint cursorPosition() const;
 
625
 
 
626
      // the window onto the terminal screen which this display
 
627
      // is currently showing.
 
628
      QPointer<ScreenWindow> _screenWindow;
 
629
 
 
630
      bool _allowBell;
 
631
 
 
632
      QGridLayout* _gridLayout;
 
633
 
 
634
      bool _fixedFont; // has fixed pitch
 
635
      int  _fontHeight;     // height
 
636
      int  _fontWidth;     // width
 
637
      int  _fontAscent;     // ascend
 
638
 
 
639
      int _leftMargin;    // offset
 
640
      int _topMargin;    // offset
 
641
 
 
642
      int _lines;      // the number of lines that can be displayed in the widget
 
643
      int _columns;    // the number of columns that can be displayed in the widget
 
644
 
 
645
      int _usedLines;  // the number of lines that are actually being used, this will be less
 
646
      // than 'lines' if the character image provided with setImage() is smaller
 
647
      // than the maximum image size which can be displayed
 
648
 
 
649
      int _usedColumns; // the number of columns that are actually being used, this will be less
 
650
      // than 'columns' if the character image provided with setImage() is smaller
 
651
      // than the maximum image size which can be displayed
 
652
 
 
653
      int _contentHeight;
 
654
      int _contentWidth;
 
655
      Character* _image; // [lines][columns]
 
656
      // only the area [usedLines][usedColumns] in the image contains valid data
 
657
 
 
658
      int _imageSize;
 
659
      QVector<LineProperty> _lineProperties;
 
660
 
 
661
      ColorEntry _colorTable[TABLE_COLORS];
 
662
      uint _randomSeed;
 
663
 
 
664
      bool _resizing;
 
665
      bool _terminalSizeHint;
 
666
      bool _terminalSizeStartup;
 
667
      bool _bidiEnabled;
 
668
      bool _mouseMarks;
 
669
 
 
670
      QPoint  _iPntSel; // initial selection point
 
671
      QPoint  _pntSel; // current selection point
 
672
      QPoint  _tripleSelBegin; // help avoid flicker
 
673
      int     _actSel; // selection state
 
674
      bool    _wordSelectionMode;
 
675
      bool    _lineSelectionMode;
 
676
      bool    _preserveLineBreaks;
 
677
      bool    _columnSelectionMode;
 
678
 
 
679
      QClipboard*  _clipboard;
 
680
      QScrollBar* _scrollBar;
 
681
      ScrollBarPosition _scrollbarLocation;
 
682
      QString     _wordCharacters;
 
683
      int         _bellMode;
 
684
 
 
685
      bool _blinking;   // hide text in paintEvent
 
686
      bool _hasBlinker; // has characters to blink
 
687
      bool _cursorBlinking;     // hide cursor in paintEvent
 
688
      bool _hasBlinkingCursor;  // has blinking cursor enabled
 
689
      bool _ctrlDrag;           // require Ctrl key for drag
 
690
      TripleClickMode _tripleClickMode;
 
691
      bool _isFixedSize; //Columns / lines are locked.
 
692
      QTimer* _blinkTimer;  // active when hasBlinker
 
693
      QTimer* _blinkCursorTimer;  // active when hasBlinkingCursor
 
694
 
 
695
//    KMenu* _drop;
 
696
      QString _dropText;
 
697
      int _dndFileCount;
 
698
 
 
699
      bool _possibleTripleClick;  // is set in mouseDoubleClickEvent and deleted
 
700
      // after QApplication::doubleClickInterval() delay
 
701
 
 
702
 
 
703
      QLabel* _resizeWidget;
 
704
      QTimer* _resizeTimer;
 
705
 
 
706
      bool _flowControlWarningEnabled;
 
707
 
 
708
      //widgets related to the warning message that appears when the user presses Ctrl+S to suspend
 
709
      //terminal output - informing them what has happened and how to resume output
 
710
      QLabel* _outputSuspendedLabel;
 
711
 
 
712
      uint _lineSpacing;
 
713
 
 
714
      bool _colorsInverted; // true during visual bell
 
715
 
 
716
      QSize _size;
 
717
 
 
718
      QRgb _blendColor;
 
719
 
 
720
      // list of filters currently applied to the display.  used for links and
 
721
      // search highlight
 
722
      TerminalImageFilterChain* _filterChain;
 
723
      QRect _mouseOverHotspotArea;
 
724
 
 
725
      KeyboardCursorShape _cursorShape;
 
726
 
 
727
      // custom cursor color.  if this is invalid then the foreground
 
728
      // color of the character under the cursor is used
 
729
      QColor _cursorColor;
 
730
 
 
731
 
 
732
      struct InputMethodData
 
733
      {
 
734
        QString preeditString;
 
735
        QRect previousPreeditRect;
 
736
      };
 
737
      InputMethodData _inputMethodData;
 
738
 
 
739
      static bool _antialiasText;   // do we antialias or not
 
740
 
 
741
      //the delay in milliseconds between redrawing blinking text
 
742
      static const int BLINK_DELAY = 500;
 
743
      static const int DEFAULT_LEFT_MARGIN = 1;
 
744
      static const int DEFAULT_TOP_MARGIN = 1;
 
745
 
 
746
    public:
 
747
      static void setTransparencyEnabled( bool enable )
 
748
      {
 
749
        HAVE_TRANSPARENCY = enable;
 
750
      }
 
751
  };
 
752
 
 
753
}
 
754
 
 
755
#endif // TERMINALDISPLAY_H