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

Plasma

panelview_win.cpp

Go to the documentation of this file.
00001 /*
00002 *   This program is free software; you can redistribute it and/or modify
00003 *   it under the terms of the GNU Library General Public License version 2,
00004 *   or (at your option) any later version.
00005 *
00006 *   This program is distributed in the hope that it will be useful,
00007 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00008 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009 *   GNU General Public License for more details
00010 *
00011 *   You should have received a copy of the GNU Library General Public
00012 *   License along with this program; if not, write to the
00013 *   Free Software Foundation, Inc.,
00014 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00015 */
00016 
00017 #include "panelview.h"
00018 
00019 #include <KDebug>
00020 
00021 #include "panelcontroller.h"
00022 
00023 #include <windows.h>
00024 
00025 #define WM_APPBAR_CALLBACK ( WM_USER + 1010 )
00026 
00027 
00028 bool PanelView::registerAccessBar(bool fRegister)
00029 {
00030     if(fRegister) {
00031         setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
00032         abd.cbSize = sizeof(APPBARDATA);
00033         abd.hWnd = (HWND)winId();
00034         abd.uCallbackMessage = WM_APPBAR_CALLBACK;
00035 
00036         if(!SHAppBarMessage(ABM_NEW, &abd)) {
00037             kWarning() << "SHAppBarMessage( ABM_NEW ) failed";
00038             return false;
00039         }
00040 
00041         switch (location()) {
00042             case Plasma::TopEdge:
00043                 abd.uEdge = ABE_TOP;
00044                 break;
00045 
00046             case Plasma::BottomEdge:
00047                 abd.uEdge = ABE_BOTTOM;
00048                 break;
00049 
00050             case Plasma::LeftEdge:
00051                 abd.uEdge = ABE_LEFT;
00052                 break;
00053 
00054             case Plasma::RightEdge:
00055                 abd.uEdge = ABE_RIGHT;
00056                 break;
00057         }
00058         
00059         //appBarPosChanged();
00060 
00061     } else {
00062         SHAppBarMessage(ABM_REMOVE, &abd);
00063     }
00064     return true;
00065 }
00066 
00067 bool PanelView::winEvent( MSG* msg, long* result )
00068 {
00069     *result = 0;
00070 
00071     switch( msg->message )
00072     {
00073         case WM_APPBAR_CALLBACK:
00074             appBarCallback( msg->wParam, msg->lParam );
00075             return true;
00076 
00077         case WM_ACTIVATE:
00078             SHAppBarMessage( ABM_ACTIVATE, &abd );
00079             break;
00080 
00081         case WM_WINDOWPOSCHANGED:
00082             SHAppBarMessage( ABM_WINDOWPOSCHANGED, &abd );
00083             break;
00084 
00085         default:
00086             return false;
00087     }
00088     
00089     return false;
00090 }
00091 
00092 void PanelView::appBarCallback( WPARAM msg, LPARAM lParam )
00093 {
00094     uint uState;
00095     switch (msg) {
00096         case ABN_STATECHANGE:
00097             break;
00098 
00099         case ABN_FULLSCREENAPP:
00100             uState = SHAppBarMessage(ABM_GETSTATE, &abd);
00101             if (lParam) {
00102                 SetWindowPos(winId(), (ABS_ALWAYSONTOP & uState) ? HWND_TOPMOST : HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
00103             } else if (uState & ABS_ALWAYSONTOP) {
00104                 SetWindowPos(winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
00105             }
00106             break;
00107 
00108         case ABN_POSCHANGED:
00109             appBarPosChanged();
00110             break;
00111     }
00112 }
00113 
00114 void PanelView::appBarPosChanged()
00115 {
00116     RECT rc; 
00117 
00118     // Get the area of the entire desktop
00119     rc.left = rc.top = 0;
00120     rc.right = GetSystemMetrics( SM_CXSCREEN );
00121     rc.bottom = GetSystemMetrics( SM_CYSCREEN );
00122 
00123     switch (location()) {
00124         case Plasma::TopEdge:
00125             abd.uEdge = ABE_TOP;
00126             rc.bottom = rc.top + height();
00127             break;
00128 
00129         case Plasma::BottomEdge:
00130             abd.uEdge = ABE_BOTTOM;
00131             rc.top = rc.bottom - height();
00132             break;
00133 
00134         case Plasma::LeftEdge:
00135             abd.uEdge = ABE_LEFT;
00136             rc.right = rc.left + width();
00137             break;
00138 
00139         case Plasma::RightEdge:
00140             abd.uEdge = ABE_RIGHT;
00141             rc.left = rc.right - width();
00142             break;
00143     }
00144     
00145     appBarQuerySetPos(&rc);
00146 }
00147 
00148 void PanelView::appBarQuerySetPos(LPRECT lprc)
00149 {
00150     int iHeight = 0; 
00151     int iWidth = 0; 
00152 
00153     abd.rc = *lprc;
00154 
00155     if ((abd.uEdge == ABE_LEFT) || (abd.uEdge == ABE_RIGHT)) {
00156         iWidth = abd.rc.right - abd.rc.left;
00157         abd.rc.top = y();
00158         abd.rc.bottom = y()+height();
00159     } else {
00160         iHeight = abd.rc.bottom - abd.rc.top; 
00161         abd.rc.left = x(); 
00162         abd.rc.right = x()+width(); 
00163     }
00164 
00165     // Query the system for an approved size and position.
00166     SHAppBarMessage(ABM_QUERYPOS, &abd);
00167 
00168     // Adjust the rectangle, depending on the edge to which the 
00169     // appbar is anchored. 
00170     switch (abd.uEdge) {
00171         case ABE_LEFT:
00172             abd.rc.right = abd.rc.left + iWidth;
00173             break;
00174 
00175         case ABE_RIGHT:
00176             abd.rc.left = abd.rc.right - iWidth;
00177             break;
00178 
00179         case ABE_TOP:
00180             abd.rc.bottom = abd.rc.top + iHeight;
00181             break;
00182 
00183         case ABE_BOTTOM:
00184             abd.rc.top = abd.rc.bottom - iHeight;
00185             break;
00186     }
00187 
00188     // Pass the final bounding rectangle to the system. 
00189     SHAppBarMessage(ABM_SETPOS, &abd);
00190     
00191     // Move and size the appbar so that it conforms to the 
00192     // bounding rectangle passed to the system. 
00193     //MoveWindow(winId(), abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true); 
00194 }

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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