• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kwindowsystem_win.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE libraries
00003     Copyright (C) 2007 Laurent Montel (montel@kde.org)
00004     Copyright (C) 2007 Christian Ehrlicher (ch.ehrlicher@gmx.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "kwindowsystem.h"
00023 
00024 #include <QtGui/QDesktopWidget>
00025 #include <QtGui/QIcon>
00026 #include <QtGui/QBitmap>
00027 #include <QtGui/QPixmap>
00028 
00029 #include "kglobal.h"
00030 #include "kdebug.h"
00031 #include "klocalizedstring.h"
00032 
00033 #include <windows.h>
00034 
00035 K_GLOBAL_STATIC(QDesktopWidget, s_deskWidget)
00036 
00037 int KWindowSystem::currentDesktop()
00038 {
00039     return 1;
00040 }
00041 
00042 int KWindowSystem::numberOfDesktops()
00043 {
00044     return 1;
00045 }
00046 
00047 void KWindowSystem::setMainWindow( QWidget*, WId )
00048 {
00049     kDebug() << "KWindowSystem::setMainWindow( QWidget, WId ) isn't yet implemented!";
00050     //TODO
00051 }
00052 
00053 void KWindowSystem::setCurrentDesktop( int desktop )
00054 {
00055     kDebug() << "KWindowSystem::setCurrentDesktop( int desktop ) isn't yet implemented!";
00056     //TODO
00057 }
00058 
00059 void KWindowSystem::setOnAllDesktops( WId win, bool b )
00060 {
00061      kDebug() << "KWindowSystem::setOnAllDesktops( WId win, bool b ) isn't yet implemented!";
00062      //TODO
00063 }
00064 
00065 void KWindowSystem::setOnDesktop( WId win, int desktop )
00066 {
00067      //TODO
00068      kDebug() << "KWindowSystem::setOnDesktop( WId win, int desktop ) isn't yet implemented!";
00069 }
00070 
00071 WId KWindowSystem::activeWindow()
00072 {
00073     return GetActiveWindow();
00074 }
00075 
00076 void KWindowSystem::activateWindow( WId win, long )
00077 {
00078     SetActiveWindow( win );
00079 }
00080 
00081 void KWindowSystem::forceActiveWindow( WId win, long time )
00082 {
00083     SetActiveWindow( win );
00084     SetForegroundWindow( win );
00085 }
00086 
00087 void KWindowSystem::demandAttention( WId win, bool set )
00088 {
00089     FLASHWINFO fi;
00090     fi.cbSize = sizeof( FLASHWINFO );
00091     fi.hwnd = win;
00092     fi.dwFlags = set ? FLASHW_ALL : FLASHW_STOP;
00093     fi.uCount = 5;
00094     fi.dwTimeout = 0;
00095 
00096     FlashWindowEx( &fi );
00097 }
00098 
00099 static HBITMAP QPixmapMask2HBitmap(const QPixmap &pix)
00100 {
00101     QBitmap bm = pix.mask();
00102     if( bm.isNull() ) {
00103         bm = QBitmap( pix.size() );
00104         bm.fill( Qt::color1 );
00105     }
00106     QImage im = bm.toImage().convertToFormat( QImage::Format_Mono );
00107     im.invertPixels();                  // funny blank'n'white games on windows
00108     int w = im.width();
00109     int h = im.height();
00110     int bpl = (( w + 15 ) / 16 ) * 2;   // bpl, 16 bit alignment
00111     QByteArray bits( bpl * h, '\0' );
00112     for (int y=0; y < h; y++)
00113         memcpy( bits.data() + y * bpl, im.scanLine( y ), bpl );
00114     return CreateBitmap( w, h, 1, 1, bits );
00115 }
00116 
00117 static HICON QPixmap2HIcon(const QPixmap &pix)
00118 {
00119     if ( pix.isNull() )
00120         return 0;
00121 
00122     ICONINFO ii;
00123     ii.fIcon    = true;
00124     ii.hbmMask  = QPixmapMask2HBitmap( pix );
00125     ii.hbmColor = pix.toWinHBITMAP( QPixmap::PremultipliedAlpha );
00126     ii.xHotspot = 0;
00127     ii.yHotspot = 0;
00128     HICON result = CreateIconIndirect( &ii );
00129 
00130     DeleteObject( ii.hbmMask );
00131     DeleteObject( ii.hbmColor );
00132 
00133     return result;
00134 }
00135 
00136 static QPixmap HIcon2QPixmap( HICON hIcon )
00137 {
00138     ICONINFO ii;
00139     if( GetIconInfo( hIcon, &ii ) == NULL )
00140         return QPixmap();
00141 
00142     QPixmap pix  = QPixmap::fromWinHBITMAP( ii.hbmColor );
00143     pix.setMask( QPixmap::fromWinHBITMAP( ii.hbmMask ) );
00144 
00145     return pix;
00146 }
00147 
00148 QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale )
00149 {
00150     UINT size = ICON_BIG;
00151     if( width < 24 || height < 24 )
00152         size = ICON_SMALL;
00153     HICON hIcon = (HICON)SendMessage( win, WM_GETICON, size, 0);
00154     QPixmap pm = HIcon2QPixmap( hIcon );
00155     if( scale )
00156         pm = pm.scaled( width, height );
00157     return pm;
00158 }
00159 
00160 class hIconCache
00161 {
00162 public:
00163     ~hIconCache()
00164     {
00165         Q_FOREACH(HICON hIcon, m_iconList)
00166             DestroyIcon(hIcon);
00167     }
00168     QList<HICON> m_iconList;
00169 };
00170 K_GLOBAL_STATIC(hIconCache, s_iconCache)
00171 
00172 QPixmap KWindowSystem::icon( WId win, int width, int height, bool scale, int )
00173 {
00174     return icon( win, width, height, scale );
00175 }
00176 
00177 void KWindowSystem::setIcons( WId win, const QPixmap& icon, const QPixmap& miniIcon )
00178 {
00179     HICON hIconBig = QPixmap2HIcon(icon);
00180     HICON hIconSmall = QPixmap2HIcon(miniIcon);
00181     if(hIconBig)
00182         s_iconCache->m_iconList.append(hIconBig);
00183     if(hIconSmall)
00184         s_iconCache->m_iconList.append(hIconSmall);
00185 
00186     hIconBig = (HICON)SendMessage( win, WM_SETICON, ICON_BIG,   (LPARAM)hIconBig );
00187     hIconSmall = (HICON)SendMessage( win, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall );
00188     
00189     s_iconCache->m_iconList.removeAll(hIconBig);
00190     s_iconCache->m_iconList.removeAll(hIconSmall);
00191 }
00192 
00193 
00194 void KWindowSystem::setState( WId win, unsigned long state )
00195 {
00196    //TODO
00197    kDebug() << "KWindowSystem::setState( WId win, unsigned long state ) isn't yet implemented!";
00198 }
00199 
00200 void KWindowSystem::clearState( WId win, unsigned long state )
00201 {
00202     //TODO
00203     kDebug() << "KWindowSystem::clearState( WId win, unsigned long state ) isn't yet implemented!";
00204 }
00205 
00206 void KWindowSystem::minimizeWindow( WId win, bool animation)
00207 {
00208     Q_UNUSED( animation );
00209     ShowWindow( win, SW_MINIMIZE );
00210 }
00211 
00212 void KWindowSystem::unminimizeWindow( WId win, bool animation )
00213 {
00214     Q_UNUSED( animation );
00215     ShowWindow( win, SW_RESTORE );
00216 }
00217 
00218 void KWindowSystem::raiseWindow( WId win )
00219 {
00220     SetWindowPos( win, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE ); // mhhh?
00221 }
00222 
00223 void KWindowSystem::lowerWindow( WId win )
00224 {
00225     SetWindowPos( win, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE ); // mhhh?
00226 }
00227 
00228 bool KWindowSystem::compositingActive()
00229 {
00230     return false;
00231 }
00232 
00233 QRect KWindowSystem::workArea( int desktop )
00234 {
00235     return s_deskWidget->availableGeometry( desktop );
00236 }
00237 
00238 QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop )
00239 {
00240     //TODO
00241     kDebug() << "QRect KWindowSystem::workArea( const QList<WId>& exclude, int desktop ) isn't yet implemented!";
00242     return QRect();
00243 }
00244 
00245 QString KWindowSystem::desktopName( int desktop )
00246 {
00247     return i18n("Desktop %1",  desktop );
00248 }
00249 
00250 void KWindowSystem::setDesktopName( int desktop, const QString& name )
00251 {
00252      kDebug() << "KWindowSystem::setDesktopName( int desktop, const QString& name ) isn't yet implemented!";
00253     //TODO
00254 }
00255 
00256 bool KWindowSystem::showingDesktop()
00257 {
00258     return false;
00259 }
00260 
00261 void KWindowSystem::setUserTime( WId win, long time )
00262 {
00263     kDebug() << "KWindowSystem::setUserTime( WId win, long time ) isn't yet implemented!";
00264     //TODO
00265 }
00266 
00267 bool KWindowSystem::icccmCompliantMappingState()
00268 {
00269     return false;
00270 }
00271 
00272 void KWindowSystem::connectNotify( const char* signal )
00273 {
00274   kDebug() << "connectNotify( const char* signal )  isn't yet implemented!";
00275 //TODO
00276 }
00277 
00278 void KWindowSystem::setExtendedStrut( WId win, int left_width, int left_start, int left_end,
00279         int right_width, int right_start, int right_end, int top_width, int top_start, int top_end,
00280         int bottom_width, int bottom_start, int bottom_end )
00281 {
00282   kDebug() << "KWindowSystem::setExtendedStrut isn't yet implemented!";
00283   //TODO
00284 }
00285 void KWindowSystem::setStrut( WId win, int left, int right, int top, int bottom )
00286 {
00287   kDebug() << "KWindowSystem::setStrut isn't yet implemented!";
00288   //TODO
00289 }
00290 
00291 QString KWindowSystem::readNameProperty( WId window, unsigned long atom )
00292 {
00293   //TODO
00294   kDebug() << "QString KWindowSystem::readNameProperty( WId window, unsigned long atom ) isn't yet implemented!";
00295   return QString();
00296 }
00297 
00298 void KWindowSystem::doNotManage( const QString& title )
00299 {
00300   //TODO
00301   kDebug() << "KWindowSystem::doNotManage( const QString& title ) isn't yet implemented!";
00302 }
00303 
00304 QList<WId> KWindowSystem::stackingOrder()
00305 {
00306   //TODO
00307   QList<WId> lst;
00308   kDebug() << "QList<WId> KWindowSystem::stackingOrder() isn't yet implemented!";
00309   return lst;
00310 }
00311 
00312 const QList<WId>& KWindowSystem::windows()
00313 {
00314   //TODO
00315   static QList<WId> lst;
00316   kDebug() << "const QList<WId>& KWindowSystem::windows()  isn't yet implemented!";
00317   return lst;
00318 }
00319 
00320 void KWindowSystem::setType( WId win, NET::WindowType windowType )
00321 {
00322  //TODO
00323  kDebug() << "setType( WId win, NET::WindowType windowType ) isn't yet implemented!";
00324 }
00325 
00326 #include "kwindowsystem.moc"
00327 

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal