webengine/osswebengine/WebCore/platform/symbian/PlatformScrollbarSymbian.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "config.h"
       
    20 
       
    21 #include "PlatformScrollbar.h"
       
    22 #include "GraphicsContext.h"
       
    23 #include "WebCoreGraphicsContext.h"
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <bitstd.h>
       
    27 
       
    28 using namespace WebCore;
       
    29 
       
    30 int PlatformScrollbar::horizontalScrollbarHeight() { return KScrollbarWidth; }
       
    31 int PlatformScrollbar::verticalScrollbarWidth() { return KScrollbarWidth; }
       
    32 
       
    33 PlatformScrollbar::PlatformScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize) 
       
    34 : Scrollbar(client, orientation, controlSize), m_rect(0,0,KScrollbarWidth,KScrollbarWidth)
       
    35 { 
       
    36 }
       
    37 
       
    38 PlatformScrollbar::~PlatformScrollbar() { }
       
    39 
       
    40 int PlatformScrollbar::width() const 
       
    41 { 
       
    42     return m_rect.width(); 
       
    43 }
       
    44 
       
    45 int PlatformScrollbar::height() const 
       
    46 { 
       
    47     return m_rect.height(); 
       
    48 }
       
    49 
       
    50 void PlatformScrollbar::setEnabled(bool b) 
       
    51 {
       
    52     m_enabled = b;
       
    53 }
       
    54 
       
    55 void PlatformScrollbar::paint(GraphicsContext* p, const IntRect& damageRect) 
       
    56 {    
       
    57     WebCoreGraphicsContext* gc = p->platformContext();
       
    58     CFbsBitGc* gcContext( &gc->gc() );
       
    59 
       
    60     int zoomFactor = gc->view().scalingFactor();
       
    61     TRect rect = TRect(m_rect.x() * zoomFactor / 100, m_rect.y() * zoomFactor / 100, (m_rect.x() + m_rect.width()) * zoomFactor / 100, (m_rect.y() + m_rect.height()) * zoomFactor / 100);
       
    62     
       
    63     gcContext->SetPenStyle( CGraphicsContext::ENullPen );
       
    64     gcContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    65 
       
    66     TRgb bck(150,150,180);
       
    67     TRgb frg(90,90,150);
       
    68     // draw background
       
    69     gcContext->SetBrushColor( bck );
       
    70     gcContext->DrawRect( rect );
       
    71 
       
    72     TInt h = rect.Height();
       
    73     TInt w = rect.Width();
       
    74 
       
    75     TInt kx, ky, kw, kh;
       
    76     TInt scrollbarWidth = zoomFactor*KScrollbarWidth/100;
       
    77     
       
    78     float thumb = (m_visibleSize > m_totalSize) ? 1 : (m_totalSize?(float)m_visibleSize/m_totalSize:1);
       
    79     float value = (m_totalSize-m_visibleSize)?(float)m_currentPos/(m_totalSize-m_visibleSize):1;
       
    80     if (m_orientation==HorizontalScrollbar)
       
    81         {
       
    82         // compute thumb position and size
       
    83         kw = w * thumb;
       
    84         kh = h;
       
    85         kx = rect.iTl.iX + value*(w-kw);
       
    86         ky = rect.iTl.iY;
       
    87         }
       
    88     else
       
    89         {
       
    90         // compute thumb position and size
       
    91         kw = w;
       
    92         kh = h * thumb;
       
    93         kx = rect.iTl.iX;
       
    94         ky = rect.iTl.iY+ value*(h-kh);
       
    95         }
       
    96 
       
    97     gcContext->SetBrushColor(frg);
       
    98     TRect r(TPoint(kx,ky),TSize(kw,kh));
       
    99     gcContext->DrawRect(r);
       
   100 }
       
   101 
       
   102 void PlatformScrollbar::updateThumbPosition() 
       
   103 {
       
   104 }
       
   105 
       
   106 void PlatformScrollbar::updateThumbProportion() 
       
   107 {
       
   108 }
       
   109 
       
   110 void PlatformScrollbar::setRect(const IntRect& rect) 
       
   111 { 
       
   112     m_rect = rect;
       
   113 }
       
   114 
       
   115 
       
   116 void PlatformScrollbar::handleMousePressEvent(const PlatformMouseEvent&, const IntPoint& p)
       
   117 {
       
   118     clickAtPoint(p, true);
       
   119 }
       
   120 
       
   121 void PlatformScrollbar::clickAtPoint(const IntPoint& point, bool /*down*/)
       
   122 {
       
   123 }