1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : QAD_Message.cxx
25 // Author : Nicolas REJNERI
29 #include "QAD_Message.h"
30 #include "QAD_Application.h"
31 #include "QAD_Config.h"
32 #include "QAD_Tools.h"
35 #include <qpopupmenu.h>
39 enum { IdCopy, IdClear, IdSelectAll };
42 \class QAD_Message QAD_Message.h
43 \brief Messages window for Study.
47 Constructor - creates Message Log window
49 QAD_Message::QAD_Message(QWidget *parent, const char* name)
50 : QMultiLineEdit(parent, name)
52 // setting default title
53 myTitle = tr("MESSAGE_LOG_NAME");
54 // setting default prompt
56 // setting font ( from preferences )
57 QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
58 QFont myFont = QAD_Tools::stringToFont( fntSet );
59 // QFont myFont("Courier", 11);
64 // setting palette (special)
65 setPalette( QAD_Application::getPalette(true) );
66 setFocusPolicy( NoFocus );
67 // currently no text wrap
74 QAD_Message::~QAD_Message()
81 void QAD_Message::setMessage(const QString& s)
83 int line = numLines() > 0 ? numLines()-1 : 0;
84 int col = lineLength(line);
85 if (!s.isNull() && s.length() > 0) {
87 insertAt(ss, line, col, false);
93 Processes own popup manu
95 void QAD_Message::mousePressEvent(QMouseEvent* event)
97 if ( event->button() == RightButton ) {
98 QPopupMenu *popup = new QPopupMenu( this );
101 int line1, col1, line2, col2;
102 getMarkedRegion(&line1, &col1, &line2, &col2);
103 bool allSelected = getMarkedRegion(&line1, &col1, &line2, &col2) &&
104 line1 == 0 && line2 == numLines()-1 && col1 == 0 && col2 == lineLength(line2);
106 id = popup->insertItem( tr( "EDIT_COPY_CMD" ) );
107 idMap.insert(IdCopy, id);
108 id = popup->insertItem( tr( "EDIT_CLEAR_CMD" ) );
109 idMap.insert(IdClear, id);
110 popup->insertSeparator();
111 id = popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) );
112 idMap.insert(IdSelectAll, id);
113 popup->setItemEnabled( idMap[ IdCopy ], hasMarkedText() );
114 popup->setItemEnabled( idMap[ IdSelectAll ], !allSelected );
115 popup->setItemEnabled( idMap[ IdClear ], textLine(1)!=myPrompt );
117 int r = popup->exec( event->globalPos() );
120 if ( r == idMap[ IdCopy ] ) {
123 else if ( r == idMap [ IdClear ] ) {
127 else if ( r == idMap[ IdSelectAll ] ) {
133 QMultiLineEdit::mousePressEvent(event);
138 Sets prompt ( default is '>>> ' )
140 void QAD_Message::setPrompt(const QString& prompt)