• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
messagewindow.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (c) 2002 Michael Goffioul <tdeprint@swing.be>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#include "messagewindow.h"
21
22#include <tqlabel.h>
23#include <tqlayout.h>
24#include <tqtimer.h>
25#include <tqpixmap.h>
26#include <tqhbox.h>
27#include <kiconloader.h>
28#include <tdeapplication.h>
29#include <kdebug.h>
30
31TQPtrDict<MessageWindow> MessageWindow::m_windows;
32
33MessageWindow::MessageWindow( const TQString& txt, int delay, TQWidget *parent, const char *name )
34 : TQWidget( parent, name, (WFlags)(WStyle_Customize|WStyle_NoBorder|WShowModal|WType_Dialog|WDestructiveClose) )
35{
36 TQHBox *box = new TQHBox( this );
37 box->setFrameStyle( TQFrame::Panel|TQFrame::Raised );
38 box->setLineWidth( 1 );
39 box->setSpacing( 10 );
40 box->setMargin( 5 );
41 TQLabel *pix = new TQLabel( box );
42 pix->setPixmap( DesktopIcon( "tdeprint_printer" ) );
43 m_text = new TQLabel( txt, box );
44
45 TQHBoxLayout *l0 = new TQHBoxLayout( this, 0, 0 );
46 l0->addWidget( box );
47
48 m_windows.insert( parent, this );
49
50 if ( delay == 0 )
51 slotTimer();
52 else
53 TQTimer::singleShot( delay, this, TQ_SLOT( slotTimer() ) );
54}
55
56MessageWindow::~MessageWindow()
57{
58 m_windows.remove( parentWidget() );
59}
60
61void MessageWindow::slotTimer()
62{
63 TQSize psz = parentWidget()->size(), sz = sizeHint();
64 move( parentWidget()->mapToGlobal( TQPoint( (psz.width()-sz.width())/2, (psz.height()-sz.height())/2 ) ) );
65 if ( !isVisible() )
66 {
67 show();
68 tdeApp->processEvents();
69 }
70}
71
72TQString MessageWindow::text() const
73{
74 return m_text->text();
75}
76
77void MessageWindow::setText( const TQString& txt )
78{
79 m_text->setText( txt );
80}
81
82void MessageWindow::add( TQWidget *parent, const TQString& txt, int delay )
83{
84 if ( !parent )
85 kdWarning( 500 ) << "Cannot add a message window to a null parent" << endl;
86 else
87 {
88 MessageWindow *w = m_windows.find( parent );
89 if ( w )
90 w->setText( txt );
91 else
92 new MessageWindow( txt, delay, parent, "MessageWindow" );
93 }
94}
95
96void MessageWindow::remove( TQWidget *parent )
97{
98 if ( parent )
99 delete m_windows.find( parent );
100}
101
102void MessageWindow::change( TQWidget *parent, const TQString& txt )
103{
104 if ( parent )
105 {
106 MessageWindow *w = m_windows.find( parent );
107 if ( w )
108 w->setText( txt );
109 else
110 kdWarning( 500 ) << "MessageWindow::change, no message window found" << endl;
111 }
112}
113
114void MessageWindow::removeAll()
115{
116 TQPtrDictIterator<MessageWindow> it( m_windows );
117 while ( it.current() )
118 delete it.current();
119}
120
121#include "messagewindow.moc"

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.4
This website is maintained by Timothy Pearson.