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

twin

  • twin
popupinfo.cpp
1 /*****************************************************************
2  KWin - the KDE window manager
3  This file is part of the KDE project.
4 
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2002 Alexander Kellett <lypanov@kde.org>
7 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
8 
9 You can Freely distribute this program under the GNU General Public
10 License. See the file "COPYING" for the exact licensing terms.
11 ******************************************************************/
12 
13 //#define QT_CLEAN_NAMESPACE
14 #include "popupinfo.h"
15 #include "workspace.h"
16 #include "client.h"
17 #include <tqpainter.h>
18 #include <tqlabel.h>
19 #include <tqdrawutil.h>
20 #include <tqstyle.h>
21 #include <tdeglobal.h>
22 #include <fixx11h.h>
23 #include <tdeconfig.h>
24 #include <kdebug.h>
25 #include <tdelocale.h>
26 #include <tqapplication.h>
27 #include <tqdesktopwidget.h>
28 #include <kstringhandler.h>
29 #include <tdeglobalsettings.h>
30 
31 // specify externals before namespace
32 
33 namespace KWinInternal
34 {
35 
36 PopupInfo::PopupInfo( Workspace* ws, const char *name )
37  : TQWidget( 0, name ), workspace( ws )
38  {
39  m_infoString = "";
40  m_shown = false;
41  reset();
42  reconfigure();
43  connect(&m_delayedHideTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(hide()));
44 
45  TQFont f = font();
46  f.setBold( TRUE );
47  f.setPointSize( 14 );
48  setFont( f );
49 
50  }
51 
52 PopupInfo::~PopupInfo()
53  {
54  }
55 
56 
60 void PopupInfo::reset()
61  {
62  TQRect r = workspace->screenGeometry( workspace->activeScreen());
63 
64  int w = fontMetrics().width( m_infoString ) + 30;
65 
66  setGeometry(
67  (r.width()-w)/2 + r.x(), r.height()/2-fontMetrics().height()-10 + r.y(),
68  w, fontMetrics().height() + 20 );
69  }
70 
71 
75 void PopupInfo::paintEvent( TQPaintEvent* )
76  {
77  TQPainter p( this );
78  style().tqdrawPrimitive( TQStyle::PE_Panel, &p, TQRect( 0, 0, width(), height() ),
79  colorGroup(), TQStyle::Style_Default );
80  paintContents();
81  }
82 
83 
88 void PopupInfo::paintContents()
89  {
90  TQPainter p( this );
91  TQRect r( 6, 6, width()-12, height()-12 );
92 
93  p.fillRect( r, colorGroup().brush( TQColorGroup::Background ) );
94 
95  /*
96  p.setPen(Qt::white);
97  p.drawText( r, AlignCenter, m_infoString );
98  p.setPen(Qt::black);
99  r.moveBy( -1, -1 );
100  p.drawText( r, AlignCenter, m_infoString );
101  r.moveBy( -1, 0 );
102  */
103  p.drawText( r, AlignCenter, m_infoString );
104  }
105 
106 void PopupInfo::hide()
107  {
108  m_delayedHideTimer.stop();
109  TQWidget::hide();
110  TQApplication::syncX();
111  XEvent otherEvent;
112  while (XCheckTypedEvent (tqt_xdisplay(), EnterNotify, &otherEvent ) )
113  ;
114  m_shown = false;
115  }
116 
117 void PopupInfo::reconfigure()
118  {
119  TDEConfig * c(TDEGlobal::config());
120  c->setGroup("PopupInfo");
121  m_show = c->readBoolEntry("ShowPopup", false );
122  m_delayTime = c->readNumEntry("PopupHideDelay", 350 );
123  }
124 
125 void PopupInfo::showInfo(TQString infoString)
126  {
127  if (m_show)
128  {
129  m_infoString = infoString;
130  reset();
131  if (m_shown)
132  {
133  paintContents();
134  }
135  else
136  {
137  show();
138  raise();
139  m_shown = true;
140  }
141  m_delayedHideTimer.start(m_delayTime, true);
142  }
143  }
144 
145 } // namespace
146 
147 #include "popupinfo.moc"

twin

Skip menu "twin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

twin

Skip menu "twin"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.