1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/* File: "guideuitextedit.cpp", Time-stamp: <2005-04-12 14:06:47 feeley> */
/* Copyright (C) 1994-2005 by Marc Feeley, All Rights Reserved. */
/*---------------------------------------------------------------------------*/
#include "guideuitextedit.h"
#include "guideuihighlighter.h"
/*---------------------------------------------------------------------------*/
GuideUiTextEdit::GuideUiTextEdit (QWidget *parent, const char *name)
: QTextEdit (parent, name)
{
setHScrollBarMode (AlwaysOn);
setVScrollBarMode (AlwaysOn);
selectStartPara = -1;
selectEndPara = -1;
connect (this, SIGNAL(doubleClicked(int,int)),
this, SLOT(this_doubleClicked(int,int)));
connect (this, SIGNAL(cursorPositionChanged(int, int)),
this, SLOT(this_cursorPositionChanged(int, int)));
status = 0;
}
void GuideUiTextEdit::setStatusBar (QStatusBar *status)
{
this->status = status;
}
// Selects a portion of text by a special selection (yellow default)
void GuideUiTextEdit::specialSelect (int selectStartPara,
int selectStartIndex,
int selectEndPara,
int selectEndIndex)
{
this->selectStartPara = selectStartPara;
this->selectStartIndex = selectStartIndex;
this->selectEndPara = selectEndPara;
this->selectEndIndex = selectEndIndex;
reselect ();
}
// Selects the default portion of text
void GuideUiTextEdit::reselect ()
{
if (selectStartPara >= 0)
{
setSelection (selectStartPara,
selectStartIndex,
selectEndPara,
selectEndIndex,
1);
setSelectionAttributes (1, yellow, false);
}
}
void GuideUiTextEdit::removeSpecialSelection ()
{
selectStartPara = -1;
selectEndPara = -1;
removeSelection (1);
}
void GuideUiTextEdit::ensureSpecialSelectionVisible ()
{
if (selectStartPara >= 0)
{
setCursorPosition (selectStartPara, selectStartIndex);
ensureCursorVisible ();
}
}
void GuideUiTextEdit::this_doubleClicked (int para, int col)
{
((GuideUiHighlighter*)syntaxHighlighter ())->doubleClicked (para, col);
}
void GuideUiTextEdit::this_cursorPositionChanged (int para, int col)
{
if (status)
status->message (QString("Line: %1 Col: %2").arg (para+1).arg (col+1));
}
/*---------------------------------------------------------------------------*/
/* Local Variables: */
/* mode: C++ */
/* End: */
|