2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
re-base on ALv2 code. Includes (at least) relevant parts of:
linecap: Reintegrating finished LineCap feature
Patch contributed by Regina Henschel
http://svn.apache.org/viewvc?view=revision&revision=1232507
Patches contributed by Sven Jacobi
impress212: #i81610# fixed animation export
http://svn.apache.org/viewvc?view=revision&revision=1167620
impress212: drawinglayer gbuild environment changes
http://svn.apache.org/viewvc?view=revision&revision=1167627
http://svn.apache.org/viewvc?view=revision&revision=1167628
impress212: DffPropSet -> minor code improvements, removing table
http://svn.apache.org/viewvc?view=revision&revision=1167634
impress212: #158494# fixed excel import (text rotation)
http://svn.apache.org/viewvc?view=revision&revision=1167638
Patches contributed by Armin Le Grand
Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement
http://svn.apache.org/viewvc?view=revision&revision=1220836
#118728# changed indentifying definitions for Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1229961
#118838# LineGeometry creation for complicated cases optimized to
create single Polygons
http://svn.apache.org/viewvc?view=revision&revision=1236232
#119176# corrected file type detection for SVG for svg files
without xml header
http://svn.apache.org/viewvc?view=revision&revision=1309445
#118728# Extended Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1230531
#118529# solve break converters and convert commands for OLEs and images
http://svn.apache.org/viewvc?view=revision&revision=1186168
svg: added WaE changes from branch svgreplacement to trunc
http://svn.apache.org/viewvc?view=revision&revision=1222974
svg: corrected missing member initialization
http://svn.apache.org/viewvc?view=revision&revision=1226134
fix for #118525#: Using primitives for chart sub-geometry visualisation
http://svn.apache.org/viewvc?view=revision&revision=1226879
#118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert
metafiles to bitmapEx ...
http://svn.apache.org/viewvc?view=revision&revision=1293316
fix for #118525#: removed no longer used variable maOriginalMapMode, one
more exception eliminated
http://svn.apache.org/viewvc?view=revision&revision=1227097
#16758# Added buffering to the VDev usages of the VclProcessor2D derivates...
http://svn.apache.org/viewvc?view=revision&revision=1229521
#116758# Secured VDev buffer device to Vcl deinit
http://svn.apache.org/viewvc?view=revision&revision=1230574
#116758# added remembering allocated VDevs for VDevBuffer to be able to also
delete these when vcl goes down; it should never happen, but You never know
http://svn.apache.org/viewvc?view=revision&revision=1230927
#118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive
representation instead of TransparencePrimitive2D
http://svn.apache.org/viewvc?view=revision&revision=1231198
#118822# secured 3D geometry creation (slices) by subdividing the 2D
source polyPolygon early
http://svn.apache.org/viewvc?view=revision&revision=1234749
#118829# enhanced Svg gradient quality, obstacles avoided
http://svn.apache.org/viewvc?view=revision&revision=1235361
#118834# Unified usage of TextBreakupHelper as single tooling class
for i18n text primitive breakup
http://svn.apache.org/viewvc?view=revision&revision=1236110
#118853# added square pixel size limit to conversion of
TransparencePrimitive2D to Metafile action
http://svn.apache.org/viewvc?view=revision&revision=1237656
#118824# coreccted mirroring and boundrect when the graphicmanager
is used for bitmap output
http://svn.apache.org/viewvc?view=revision&revision=1240097
#115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for
various optimization scenarios
http://svn.apache.org/viewvc?view=revision&revision=1241434
#118783# Corrected errors in ID strings, corrected Svg line/fill export,
corrected polygon close state
http://svn.apache.org/viewvc?view=revision&revision=1232006
#118796# corrected null-pointer usage in SVG text exporter
http://svn.apache.org/viewvc?view=revision&revision=1240262
#118729# Use GraphicStreamUrl and GraphicUrl to allow multi image
import with linked graphics, too
http://svn.apache.org/viewvc?view=revision&revision=1229962
#118898# corrected error in GDIMetaFile::GetBoundRect in handling
MetaFloatTransparentAction
http://svn.apache.org/viewvc?view=revision&revision=1293349
#118855# Corrected handling of possibly created empty clipRegions
after PolyPolygon clipping
http://svn.apache.org/viewvc?view=revision&revision=1237725
#115962# Better (but not yet optimal, see comments in task) handling
of MetaFloatTransparentAction in PDF export
http://svn.apache.org/viewvc?view=revision&revision=1241078
IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ...
http://svn.apache.org/viewvc?view=revision&revision=1200879
118779# Added svg content streaming in/out to ImpGraphic stream operators
http://svn.apache.org/viewvc?view=revision&revision=1231908
linecap: correctons for WaE and mac drawing
http://svn.apache.org/viewvc?view=revision&revision=1232793
svg: uses current system Dpi for Svg replacement image creation
http://svn.apache.org/viewvc?view=revision&revision=1233948
Patches contributed by Mathias Bauer (and others)
gnumake4 work variously
http://svn.apache.org/viewvc?view=revision&revision=1394326
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1394326
Remove duplicate header includes.
cws mba34issues01: #i117720#: convert assertion into warning
http://svn.apache.org/viewvc?view=revision&revision=1172352
118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand.
http://svn.apache.org/viewvc?view=revision&revision=1182166
cws mba34issues01: #i117714#: remove assertion
http://svn.apache.org/viewvc?view=revision&revision=1172357
Patch contributed by Jurgen Schmidt
add some additional checks to ensure proper reading operations
http://svn.apache.org/viewvc?view=revision&revision=1209022
mostly prefer our stream / bounds checking work.
Patches contributed by Herbert Duerr
#i118816# add clarifying comment regarding Font::*Color*() methods
http://svn.apache.org/viewvc?view=revision&revision=1233833
extend macro->string handling for empty strings
http://svn.apache.org/viewvc?view=revision&revision=1175801
avoid magic constants for SALCOLOR_NONE
http://svn.apache.org/viewvc?view=revision&revision=1177543
initialize slant properly in ImplFontMetricData constructor (author=iorsh)
http://svn.apache.org/viewvc?view=revision&revision=1177551
#i118675# make check for extension updates more stable
http://svn.apache.org/viewvc?view=revision&revision=1214797
#a118617# remove VBasicEventListener.dll binary
There are no known users depending on its CLSID
http://svn.apache.org/viewvc?view=revision&revision=1203697
Patches contributed by Ariel Constenla-Haile
Fix build breaker on Linux/gcc
http://svn.apache.org/viewvc?view=revision&revision=1221104
Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG
http://svn.apache.org/viewvc?view=revision&revision=1215559
Patches contributed by Oliver-Rainer Wittmann
sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider
instances of <SwFlyDrawObj>
http://svn.apache.org/viewvc?view=revision&revision=1172120
sw34bf06: #i117783# - Writer's implementation of XPagePrintable -
apply print settings to new printing routines
http://svn.apache.org/viewvc?view=revision&revision=1172115
gnumake4 work variously from Hans-Joachim Lankenau
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1396782
http://svn.apache.org/viewvc?view=revision&revision=1394707
plus some amount of re-splitting of legacy headers.
Patch contributed by Pavel Janik
WaE: Remove unused variables.
http://svn.apache.org/viewvc?view=revision&revision=1230697
Patches contributed by Takashi Ono
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
Patch contributed by Christian Lippka
impress212: #i98044# re enable Text menu for outline and title shapes
http://svn.apache.org/viewvc?view=revision&revision=1167639
Patch contributed by Andre Fischer
118674: Made category B code optional and disabled by default.
http://svn.apache.org/viewvc?view=revision&revision=1215131
118881: Ignore empty paragraphs after bullets.
http://svn.apache.org/viewvc?view=revision&revision=1296205
Patches contributed by Philipp Lohmann
ooo340fixes: #i117780# use rtl allocator
http://svn.apache.org/viewvc?view=revision&revision=1172087
ooo34gsl02: #i117807# fix an off by one error (index actually
inside the pfb section header)
http://svn.apache.org/viewvc?view=revision&revision=1167576
various cleanups, related compilation fixes, warning cleanups, re-working
of obsolete stl template pieces to use boost instead, changed string
classes, re-adapt KDE about data, about dialog, fixing warnings,
and other fixes & improvements.
Disable svg import / render for about/ branding code-paths for now.
Restore full icon theme set.
Remove OS/2 conditionals and sources.
Remove conflicting gtk/full-screen monitors support.
Retain existing svg rasterizer files - temporarily disabled.
Standardize stringificaiton and fixup dllpostfix issues.
Rename SvgGradientHelper::== to equalTo to avoid overloading issues.
Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-03-05 16:08:17 +00:00
|
|
|
#include "vcl/event.hxx"
|
|
|
|
#include "vcl/decoview.hxx"
|
|
|
|
#include "vcl/scrbar.hxx"
|
|
|
|
#include "vcl/timer.hxx"
|
2014-01-02 23:52:37 +01:00
|
|
|
#include "vcl/settings.hxx"
|
2011-01-24 16:34:14 +01:00
|
|
|
|
|
|
|
#include "svdata.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-03-05 16:08:17 +00:00
|
|
|
#include "rtl/string.hxx"
|
|
|
|
#include "tools/rc.h"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-01-14 15:21:43 +00:00
|
|
|
/* #i77549#
|
|
|
|
HACK: for scrollbars in case of thumb rect, page up and page down rect we
|
2013-12-05 22:01:05 +02:00
|
|
|
abuse the HitTestNativeControl interface. All theming engines but OS X
|
2008-01-14 15:21:43 +00:00
|
|
|
are actually able to draw the thumb according to our internal representation.
|
2013-12-05 22:01:05 +02:00
|
|
|
However OS X draws a little outside. The canonical way would be to enhance the
|
2008-01-14 15:21:43 +00:00
|
|
|
HitTestNativeControl passing a ScrollbarValue additionally so all necessary
|
|
|
|
information is available in the call.
|
|
|
|
.
|
|
|
|
However since there is only this one small exception we will deviate a little and
|
|
|
|
instead pass the respective rect as control region to allow for a small correction.
|
|
|
|
|
|
|
|
So all places using HitTestNativeControl on PART_THUMB_HORZ, PART_THUMB_VERT,
|
|
|
|
PART_TRACK_HORZ_LEFT, PART_TRACK_HORZ_RIGHT, PART_TRACK_VERT_UPPER, PART_TRACK_VERT_LOWER
|
|
|
|
do not use the control rectangle as region but the actuall part rectangle, making
|
|
|
|
only small deviations feasible.
|
|
|
|
*/
|
|
|
|
|
2012-05-08 21:58:58 +09:00
|
|
|
#include "thumbpos.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
#define SCRBAR_DRAW_BTN1 ((sal_uInt16)0x0001)
|
|
|
|
#define SCRBAR_DRAW_BTN2 ((sal_uInt16)0x0002)
|
|
|
|
#define SCRBAR_DRAW_PAGE1 ((sal_uInt16)0x0004)
|
|
|
|
#define SCRBAR_DRAW_PAGE2 ((sal_uInt16)0x0008)
|
|
|
|
#define SCRBAR_DRAW_THUMB ((sal_uInt16)0x0010)
|
|
|
|
#define SCRBAR_DRAW_BACKGROUND ((sal_uInt16)0x0020)
|
2000-09-18 16:07:07 +00:00
|
|
|
#define SCRBAR_DRAW_ALL (SCRBAR_DRAW_BTN1 | SCRBAR_DRAW_BTN2 | \
|
|
|
|
SCRBAR_DRAW_PAGE1 | SCRBAR_DRAW_PAGE2 |\
|
2004-05-10 14:47:32 +00:00
|
|
|
SCRBAR_DRAW_THUMB | SCRBAR_DRAW_BACKGROUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-09-29 15:46:40 +08:00
|
|
|
#define SCRBAR_STATE_BTN1_DOWN ((sal_uInt16)0x0001)
|
|
|
|
#define SCRBAR_STATE_BTN1_DISABLE ((sal_uInt16)0x0002)
|
|
|
|
#define SCRBAR_STATE_BTN2_DOWN ((sal_uInt16)0x0004)
|
|
|
|
#define SCRBAR_STATE_BTN2_DISABLE ((sal_uInt16)0x0008)
|
|
|
|
#define SCRBAR_STATE_PAGE1_DOWN ((sal_uInt16)0x0010)
|
|
|
|
#define SCRBAR_STATE_PAGE2_DOWN ((sal_uInt16)0x0020)
|
|
|
|
#define SCRBAR_STATE_THUMB_DOWN ((sal_uInt16)0x0040)
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#define SCRBAR_VIEW_STYLE (WB_3DLOOK | WB_HORZ | WB_VERT)
|
|
|
|
|
2003-12-11 10:52:30 +00:00
|
|
|
struct ImplScrollBarData
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
AutoTimer maTimer; // Timer
|
2013-05-16 09:16:53 +09:00
|
|
|
bool mbHide;
|
2007-09-13 15:33:31 +00:00
|
|
|
Rectangle maTrackRect; // TODO: move to ScrollBar class when binary incompatibility of ScrollBar class is no longer problematic
|
2003-12-11 10:52:30 +00:00
|
|
|
};
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void ScrollBar::ImplInit( vcl::Window* pParent, WinBits nStyle )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-12-11 10:52:30 +00:00
|
|
|
mpData = NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
mnThumbPixRange = 0;
|
|
|
|
mnThumbPixPos = 0;
|
|
|
|
mnThumbPixSize = 0;
|
|
|
|
mnMinRange = 0;
|
|
|
|
mnMaxRange = 100;
|
|
|
|
mnThumbPos = 0;
|
|
|
|
mnVisibleSize = 0;
|
|
|
|
mnLineSize = 1;
|
|
|
|
mnPageSize = 1;
|
|
|
|
mnDelta = 0;
|
|
|
|
mnDragDraw = 0;
|
|
|
|
mnStateFlags = 0;
|
|
|
|
meScrollType = SCROLL_DONTKNOW;
|
|
|
|
meDDScrollType = SCROLL_DONTKNOW;
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = true;
|
|
|
|
mbFullDrag = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
if( !mpData ) // TODO: remove when maTrackRect is no longer in mpData
|
|
|
|
{
|
|
|
|
mpData = new ImplScrollBarData;
|
|
|
|
mpData->maTimer.SetTimeoutHdl( LINK( this, ScrollBar, ImplAutoTimerHdl ) );
|
2013-05-16 09:16:53 +09:00
|
|
|
mpData->mbHide = false;
|
2007-09-13 15:33:31 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplInitStyle( nStyle );
|
|
|
|
Control::ImplInit( pParent, nStyle, NULL );
|
|
|
|
|
|
|
|
long nScrollSize = GetSettings().GetStyleSettings().GetScrollBarSize();
|
|
|
|
SetSizePixel( Size( nScrollSize, nScrollSize ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::ImplInitStyle( WinBits nStyle )
|
|
|
|
{
|
|
|
|
if ( nStyle & WB_DRAG )
|
2014-02-21 12:53:51 +01:00
|
|
|
mbFullDrag = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2015-05-20 14:46:54 +02:00
|
|
|
mbFullDrag = bool(GetSettings().GetStyleSettings().GetDragFullOptions() & DragFullOptions::Scroll);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScrollBar::ScrollBar( vcl::Window* pParent, WinBits nStyle ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
Control( WINDOW_SCROLLBAR )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar::~ScrollBar()
|
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-12 11:38:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::dispose()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-02-12 15:29:18 +02:00
|
|
|
delete mpData; mpData = NULL;
|
2015-01-12 11:38:12 +02:00
|
|
|
Control::dispose();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
void ScrollBar::ImplUpdateRects( bool bUpdate )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nOldStateFlags = mnStateFlags;
|
2000-09-18 16:07:07 +00:00
|
|
|
Rectangle aOldPage1Rect = maPage1Rect;
|
|
|
|
Rectangle aOldPage2Rect = maPage2Rect;
|
|
|
|
Rectangle aOldThumbRect = maThumbRect;
|
|
|
|
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_BTN1_DISABLE;
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_BTN2_DISABLE;
|
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
Rectangle& maTrackRect = mpData->maTrackRect; // TODO: remove when maTrackRect is no longer in mpData
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mnThumbPixRange )
|
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maThumbRect.Left() = maTrackRect.Left()+mnThumbPixPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
maThumbRect.Right() = maThumbRect.Left()+mnThumbPixSize-1;
|
|
|
|
if ( !mnThumbPixPos )
|
|
|
|
maPage1Rect.Right() = RECT_EMPTY;
|
|
|
|
else
|
|
|
|
maPage1Rect.Right() = maThumbRect.Left()-1;
|
|
|
|
if ( mnThumbPixPos >= (mnThumbPixRange-mnThumbPixSize) )
|
|
|
|
maPage2Rect.Right() = RECT_EMPTY;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maPage2Rect.Left() = maThumbRect.Right()+1;
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage2Rect.Right() = maTrackRect.Right();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maThumbRect.Top() = maTrackRect.Top()+mnThumbPixPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
maThumbRect.Bottom() = maThumbRect.Top()+mnThumbPixSize-1;
|
|
|
|
if ( !mnThumbPixPos )
|
|
|
|
maPage1Rect.Bottom() = RECT_EMPTY;
|
|
|
|
else
|
|
|
|
maPage1Rect.Bottom() = maThumbRect.Top()-1;
|
|
|
|
if ( mnThumbPixPos >= (mnThumbPixRange-mnThumbPixSize) )
|
|
|
|
maPage2Rect.Bottom() = RECT_EMPTY;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
maPage2Rect.Top() = maThumbRect.Bottom()+1;
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage2Rect.Bottom() = maTrackRect.Bottom();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
const long nSpace = maTrackRect.Right() - maTrackRect.Left();
|
|
|
|
if ( nSpace > 0 )
|
2004-09-08 14:55:40 +00:00
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage1Rect.Left() = maTrackRect.Left();
|
|
|
|
maPage1Rect.Right() = maTrackRect.Left() + (nSpace/2);
|
|
|
|
maPage2Rect.Left() = maPage1Rect.Right() + 1;
|
|
|
|
maPage2Rect.Right() = maTrackRect.Right();
|
2004-09-08 14:55:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
const long nSpace = maTrackRect.Bottom() - maTrackRect.Top();
|
|
|
|
if ( nSpace > 0 )
|
2004-09-08 14:55:40 +00:00
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage1Rect.Top() = maTrackRect.Top();
|
|
|
|
maPage1Rect.Bottom() = maTrackRect.Top() + (nSpace/2);
|
|
|
|
maPage2Rect.Top() = maPage1Rect.Bottom() + 1;
|
|
|
|
maPage2Rect.Bottom() = maTrackRect.Bottom();
|
2004-09-08 14:55:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:47:32 +00:00
|
|
|
if( !IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
// disable scrollbar buttons only in VCL's own 'theme'
|
|
|
|
// as it is uncommon on other platforms
|
|
|
|
if ( mnThumbPos == mnMinRange )
|
|
|
|
mnStateFlags |= SCRBAR_STATE_BTN1_DISABLE;
|
|
|
|
if ( mnThumbPos >= (mnMaxRange-mnVisibleSize) )
|
|
|
|
mnStateFlags |= SCRBAR_STATE_BTN2_DISABLE;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( bUpdate )
|
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nDraw = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( (nOldStateFlags & SCRBAR_STATE_BTN1_DISABLE) !=
|
|
|
|
(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) )
|
|
|
|
nDraw |= SCRBAR_DRAW_BTN1;
|
|
|
|
if ( (nOldStateFlags & SCRBAR_STATE_BTN2_DISABLE) !=
|
|
|
|
(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) )
|
|
|
|
nDraw |= SCRBAR_DRAW_BTN2;
|
|
|
|
if ( aOldPage1Rect != maPage1Rect )
|
|
|
|
nDraw |= SCRBAR_DRAW_PAGE1;
|
|
|
|
if ( aOldPage2Rect != maPage2Rect )
|
|
|
|
nDraw |= SCRBAR_DRAW_PAGE2;
|
|
|
|
if ( aOldThumbRect != maThumbRect )
|
2006-06-19 18:18:42 +00:00
|
|
|
nDraw |= SCRBAR_DRAW_THUMB;
|
2015-05-07 12:12:34 +09:00
|
|
|
Invalidate();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
long ScrollBar::ImplCalcThumbPos( long nPixPos )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// Calculate position
|
2000-09-18 16:07:07 +00:00
|
|
|
long nCalcThumbPos;
|
|
|
|
nCalcThumbPos = ImplMulDiv( nPixPos, mnMaxRange-mnVisibleSize-mnMinRange,
|
|
|
|
mnThumbPixRange-mnThumbPixSize );
|
|
|
|
nCalcThumbPos += mnMinRange;
|
|
|
|
return nCalcThumbPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
long ScrollBar::ImplCalcThumbPosPix( long nPos )
|
|
|
|
{
|
|
|
|
long nCalcThumbPos;
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Calculate position
|
2000-09-18 16:07:07 +00:00
|
|
|
nCalcThumbPos = ImplMulDiv( nPos-mnMinRange, mnThumbPixRange-mnThumbPixSize,
|
|
|
|
mnMaxRange-mnVisibleSize-mnMinRange );
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// At the start and end of the ScrollBar, we try to show the display correctly
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !nCalcThumbPos && (mnThumbPos > mnMinRange) )
|
|
|
|
nCalcThumbPos = 1;
|
|
|
|
if ( nCalcThumbPos &&
|
|
|
|
((nCalcThumbPos+mnThumbPixSize) >= mnThumbPixRange) &&
|
|
|
|
(mnThumbPos < (mnMaxRange-mnVisibleSize)) )
|
|
|
|
nCalcThumbPos--;
|
|
|
|
|
|
|
|
return nCalcThumbPos;
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
void ScrollBar::ImplCalc( bool bUpdate )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
const Size aSize = GetOutputSizePixel();
|
2011-12-14 14:43:58 -05:00
|
|
|
const long nMinThumbSize = GetSettings().GetStyleSettings().GetMinThumbSize();
|
2004-09-08 14:55:40 +00:00
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
Rectangle& maTrackRect = mpData->maTrackRect; // TODO: remove when maTrackRect is no longer in mpData
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mbCalcSize )
|
|
|
|
{
|
2012-12-04 16:16:14 +00:00
|
|
|
Size aOldSize = getCurrentCalcSize();
|
2012-10-08 15:40:34 +01:00
|
|
|
|
2010-07-05 11:20:24 +02:00
|
|
|
const Rectangle aControlRegion( Point(0,0), aSize );
|
|
|
|
Rectangle aBtn1Region, aBtn2Region, aTrackRegion, aBoundingRegion;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
{
|
2013-06-28 21:52:17 +04:00
|
|
|
if ( GetNativeControlRegion( CTRL_SCROLLBAR, IsRTLEnabled()? PART_BUTTON_RIGHT: PART_BUTTON_LEFT,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aBtn1Region ) &&
|
2013-06-28 21:52:17 +04:00
|
|
|
GetNativeControlRegion( CTRL_SCROLLBAR, IsRTLEnabled()? PART_BUTTON_LEFT: PART_BUTTON_RIGHT,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aBtn2Region ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-07-05 11:20:24 +02:00
|
|
|
maBtn1Rect = aBtn1Region;
|
|
|
|
maBtn2Rect = aBtn2Region;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
Size aBtnSize( aSize.Height(), aSize.Height() );
|
2004-10-22 11:13:38 +00:00
|
|
|
maBtn2Rect.Top() = maBtn1Rect.Top();
|
2004-09-08 14:55:40 +00:00
|
|
|
maBtn2Rect.Left() = aSize.Width()-aSize.Height();
|
|
|
|
maBtn1Rect.SetSize( aBtnSize );
|
|
|
|
maBtn2Rect.SetSize( aBtnSize );
|
|
|
|
}
|
2007-09-13 15:33:31 +00:00
|
|
|
|
|
|
|
if ( GetNativeControlRegion( CTRL_SCROLLBAR, PART_TRACK_HORZ_AREA,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aTrackRegion ) )
|
2010-07-05 11:20:24 +02:00
|
|
|
maTrackRect = aTrackRegion;
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
2007-09-13 15:33:31 +00:00
|
|
|
maTrackRect = Rectangle( maBtn1Rect.TopRight(), maBtn2Rect.BottomLeft() );
|
2004-09-08 14:55:40 +00:00
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
// Check if available space is big enough for thumb ( min thumb size = ScrBar width/height )
|
|
|
|
mnThumbPixRange = maTrackRect.Right() - maTrackRect.Left();
|
|
|
|
if( mnThumbPixRange > 0 )
|
2004-09-08 14:55:40 +00:00
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage1Rect.Left() = maTrackRect.Left();
|
|
|
|
maPage1Rect.Bottom() =
|
|
|
|
maPage2Rect.Bottom() =
|
|
|
|
maThumbRect.Bottom() = maTrackRect.Bottom();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
mnThumbPixRange = 0;
|
2004-09-08 14:55:40 +00:00
|
|
|
maPage1Rect.SetEmpty();
|
|
|
|
maPage2Rect.SetEmpty();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-08 14:55:40 +00:00
|
|
|
if ( GetNativeControlRegion( CTRL_SCROLLBAR, PART_BUTTON_UP,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aBtn1Region ) &&
|
2004-09-08 14:55:40 +00:00
|
|
|
GetNativeControlRegion( CTRL_SCROLLBAR, PART_BUTTON_DOWN,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aBtn2Region ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-07-05 11:20:24 +02:00
|
|
|
maBtn1Rect = aBtn1Region;
|
|
|
|
maBtn2Rect = aBtn2Region;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
const Size aBtnSize( aSize.Width(), aSize.Width() );
|
2004-10-22 11:13:38 +00:00
|
|
|
maBtn2Rect.Left() = maBtn1Rect.Left();
|
2004-09-08 14:55:40 +00:00
|
|
|
maBtn2Rect.Top() = aSize.Height()-aSize.Width();
|
|
|
|
maBtn1Rect.SetSize( aBtnSize );
|
|
|
|
maBtn2Rect.SetSize( aBtnSize );
|
|
|
|
}
|
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
if ( GetNativeControlRegion( CTRL_SCROLLBAR, PART_TRACK_VERT_AREA,
|
2014-12-30 16:26:11 +02:00
|
|
|
aControlRegion, ControlState::NONE, ImplControlValue(), OUString(), aBoundingRegion, aTrackRegion ) )
|
2010-07-05 11:20:24 +02:00
|
|
|
maTrackRect = aTrackRegion;
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
2007-09-13 15:33:31 +00:00
|
|
|
maTrackRect = Rectangle( maBtn1Rect.BottomLeft()+Point(0,1), maBtn2Rect.TopRight() );
|
2004-09-08 14:55:40 +00:00
|
|
|
|
2007-09-13 15:33:31 +00:00
|
|
|
// Check if available space is big enough for thumb
|
|
|
|
mnThumbPixRange = maTrackRect.Bottom() - maTrackRect.Top();
|
|
|
|
if( mnThumbPixRange > 0 )
|
2004-09-08 14:55:40 +00:00
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
maPage1Rect.Top() = maTrackRect.Top();
|
|
|
|
maPage1Rect.Right() =
|
|
|
|
maPage2Rect.Right() =
|
|
|
|
maThumbRect.Right() = maTrackRect.Right();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
|
|
|
{
|
2007-09-13 15:33:31 +00:00
|
|
|
mnThumbPixRange = 0;
|
2004-09-08 14:55:40 +00:00
|
|
|
maPage1Rect.SetEmpty();
|
|
|
|
maPage2Rect.SetEmpty();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !mnThumbPixRange )
|
|
|
|
maThumbRect.SetEmpty();
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = false;
|
2012-10-08 15:40:34 +01:00
|
|
|
|
2012-12-04 16:16:14 +00:00
|
|
|
Size aNewSize = getCurrentCalcSize();
|
2012-10-08 15:40:34 +01:00
|
|
|
if (aOldSize != aNewSize)
|
|
|
|
{
|
|
|
|
queue_resize();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mnThumbPixRange )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// Calculate values
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( (mnVisibleSize >= (mnMaxRange-mnMinRange)) ||
|
|
|
|
((mnMaxRange-mnMinRange) <= 0) )
|
|
|
|
{
|
|
|
|
mnThumbPos = mnMinRange;
|
|
|
|
mnThumbPixPos = 0;
|
|
|
|
mnThumbPixSize = mnThumbPixRange;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( mnVisibleSize )
|
|
|
|
mnThumbPixSize = ImplMulDiv( mnThumbPixRange, mnVisibleSize, mnMaxRange-mnMinRange );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
mnThumbPixSize = maThumbRect.GetWidth();
|
2004-09-08 14:55:40 +00:00
|
|
|
else
|
|
|
|
mnThumbPixSize = maThumbRect.GetHeight();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-09-08 14:55:40 +00:00
|
|
|
if ( mnThumbPixSize < nMinThumbSize )
|
|
|
|
mnThumbPixSize = nMinThumbSize;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mnThumbPixSize > mnThumbPixRange )
|
|
|
|
mnThumbPixSize = mnThumbPixRange;
|
|
|
|
mnThumbPixPos = ImplCalcThumbPosPix( mnThumbPos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// If we're ought to ouput again and we have been triggered
|
|
|
|
// a Paint event via an Action, we don't output directly,
|
|
|
|
// but invalidate everything
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bUpdate && HasPaintEvent() )
|
|
|
|
{
|
|
|
|
Invalidate();
|
2014-02-21 12:53:51 +01:00
|
|
|
bUpdate = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
ImplUpdateRects( bUpdate );
|
|
|
|
}
|
|
|
|
|
2015-05-27 09:37:41 +02:00
|
|
|
void ScrollBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& /* rSize */, DrawFlags nFlags )
|
2003-12-11 10:52:30 +00:00
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
Point aPos = pDev->LogicToPixel( rPos );
|
2003-12-11 10:52:30 +00:00
|
|
|
|
|
|
|
pDev->Push();
|
|
|
|
pDev->SetMapMode();
|
2015-05-27 09:37:41 +02:00
|
|
|
if ( !(nFlags & DrawFlags::Mono) )
|
2003-12-11 10:52:30 +00:00
|
|
|
{
|
|
|
|
// DecoView uses the FaceColor...
|
|
|
|
AllSettings aSettings = pDev->GetSettings();
|
|
|
|
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
|
|
|
|
if ( IsControlBackground() )
|
|
|
|
aStyleSettings.SetFaceColor( GetControlBackground() );
|
|
|
|
else
|
|
|
|
aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
|
|
|
|
|
|
|
|
aSettings.SetStyleSettings( aStyleSettings );
|
|
|
|
pDev->SetSettings( aSettings );
|
|
|
|
}
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// For printing:
|
|
|
|
// - calculate the size of the rects
|
|
|
|
// - because this is zero-based add the correct offset
|
|
|
|
// - print
|
|
|
|
// - force recalculate
|
2003-12-11 10:52:30 +00:00
|
|
|
|
|
|
|
if ( mbCalcSize )
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplCalc( false );
|
2003-12-11 10:52:30 +00:00
|
|
|
|
|
|
|
maBtn1Rect+=aPos;
|
|
|
|
maBtn2Rect+=aPos;
|
|
|
|
maThumbRect+=aPos;
|
2007-09-13 15:33:31 +00:00
|
|
|
mpData->maTrackRect+=aPos; // TODO: update when maTrackRect is no longer in mpData
|
2003-12-11 10:52:30 +00:00
|
|
|
maPage1Rect+=aPos;
|
|
|
|
maPage2Rect+=aPos;
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
ImplDraw(*pDev, SCRBAR_DRAW_ALL);
|
2003-12-11 10:52:30 +00:00
|
|
|
pDev->Pop();
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = true;
|
2003-12-11 10:52:30 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
bool ScrollBar::ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2010-07-05 11:20:24 +02:00
|
|
|
ScrollbarValue scrValue;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
bool bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
|
|
|
|
if (!bNativeOK)
|
2014-02-21 12:53:51 +01:00
|
|
|
return false;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-04-24 12:34:53 +02:00
|
|
|
bool bHorz = (GetStyle() & WB_HORZ) != 0;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2013-06-29 15:01:11 +04:00
|
|
|
// Draw the entire background if the control supports it
|
2015-05-07 12:12:34 +09:00
|
|
|
if (rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT))
|
2013-06-29 15:01:11 +04:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
ControlState nState = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
|
|
|
|
| (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
|
2013-06-29 15:01:11 +04:00
|
|
|
|
|
|
|
scrValue.mnMin = mnMinRange;
|
|
|
|
scrValue.mnMax = mnMaxRange;
|
|
|
|
scrValue.mnCur = mnThumbPos;
|
|
|
|
scrValue.mnVisibleSize = mnVisibleSize;
|
|
|
|
scrValue.maThumbRect = maThumbRect;
|
|
|
|
scrValue.maButton1Rect = maBtn1Rect;
|
|
|
|
scrValue.maButton2Rect = maBtn2Rect;
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnButton1State = ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? ControlState::PRESSED : ControlState::NONE) |
|
|
|
|
((!(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)) ? ControlState::ENABLED : ControlState::NONE);
|
|
|
|
scrValue.mnButton2State = ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE) |
|
|
|
|
((!(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)) ? ControlState::ENABLED : ControlState::NONE);
|
|
|
|
scrValue.mnThumbState = nState | ((mnStateFlags & SCRBAR_STATE_THUMB_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
|
|
|
scrValue.mnPage1State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
|
|
|
scrValue.mnPage2State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
2013-06-29 15:01:11 +04:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (IsMouseOver())
|
2013-06-29 15:01:11 +04:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
|
|
|
|
if (pRect)
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (pRect == &maThumbRect)
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnThumbState |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maBtn1Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnButton1State |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maBtn2Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnButton2State |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maPage1Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnPage1State |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maPage2Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
scrValue.mnPage2State |= ControlState::ROLLOVER;
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-29 15:01:11 +04:00
|
|
|
|
|
|
|
Rectangle aCtrlRegion;
|
2015-05-07 12:12:34 +09:00
|
|
|
aCtrlRegion.Union(maBtn1Rect);
|
|
|
|
aCtrlRegion.Union(maBtn2Rect);
|
|
|
|
aCtrlRegion.Union(maPage1Rect);
|
|
|
|
aCtrlRegion.Union(maPage2Rect);
|
|
|
|
aCtrlRegion.Union(maThumbRect);
|
2014-12-31 17:25:05 +09:00
|
|
|
|
2015-06-23 10:29:48 +02:00
|
|
|
Rectangle aRequestedRegion(Point(0,0), GetOutputSizePixel());
|
2014-12-31 17:25:05 +09:00
|
|
|
// if the actual native control region is smaller then the region that
|
|
|
|
// we requested the control to draw in, then draw a background rectangle
|
|
|
|
// to avoid drawing artifacts in the uncovered region
|
|
|
|
if (aCtrlRegion.GetWidth() < aRequestedRegion.GetWidth() ||
|
|
|
|
aCtrlRegion.GetHeight() < aRequestedRegion.GetHeight())
|
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
Color aFaceColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
|
|
|
|
rRenderContext.SetFillColor(aFaceColor);
|
|
|
|
rRenderContext.SetLineColor(aFaceColor);
|
|
|
|
rRenderContext.DrawRect(aRequestedRegion);
|
2014-12-31 17:25:05 +09:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
|
|
|
|
aCtrlRegion, nState, scrValue, OUString());
|
2013-06-29 15:01:11 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2))
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
sal_uInt32 part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
|
|
|
|
sal_uInt32 part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER;
|
|
|
|
Rectangle aCtrlRegion1(maPage1Rect);
|
|
|
|
Rectangle aCtrlRegion2(maPage2Rect);
|
|
|
|
ControlState nState1 = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
|
|
|
|
| (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
|
2004-05-10 14:47:32 +00:00
|
|
|
ControlState nState2 = nState1;
|
|
|
|
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 |= ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
|
|
|
nState2 |= ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (IsMouseOver())
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
|
|
|
|
if (pRect)
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (pRect == &maPage1Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maPage2Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState2 |= ControlState::ROLLOVER;
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (nDrawFlags & SCRBAR_DRAW_PAGE1)
|
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (nDrawFlags & SCRBAR_DRAW_PAGE2)
|
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
2015-05-07 12:12:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2))
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
sal_uInt32 part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP;
|
|
|
|
sal_uInt32 part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
|
|
|
|
Rectangle aCtrlRegion1(maBtn1Rect);
|
|
|
|
Rectangle aCtrlRegion2(maBtn2Rect);
|
2014-12-30 16:26:11 +02:00
|
|
|
ControlState nState1 = HasFocus() ? ControlState::FOCUSED : ControlState::NONE;
|
2004-05-10 14:47:32 +00:00
|
|
|
ControlState nState2 = nState1;
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (!Window::IsEnabled() || !IsEnabled())
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 = (nState2 &= ~ControlState::ENABLED);
|
2004-05-10 14:47:32 +00:00
|
|
|
else
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 = (nState2 |= ControlState::ENABLED);
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 |= ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
|
|
|
nState2 |= ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 &= ~ControlState::ENABLED;
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState2 &= ~ControlState::ENABLED;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (IsMouseOver())
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
|
|
|
|
if (pRect)
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (pRect == &maBtn1Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState1 |= ControlState::ROLLOVER;
|
2015-05-07 12:12:34 +09:00
|
|
|
else if (pRect == &maBtn2Rect)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState2 |= ControlState::ROLLOVER;
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (nDrawFlags & SCRBAR_DRAW_BTN1)
|
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (nDrawFlags & SCRBAR_DRAW_BTN2)
|
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
2015-05-07 12:12:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty())
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
ControlState nState = IsEnabled() ? ControlState::ENABLED : ControlState::NONE;
|
|
|
|
Rectangle aCtrlRegion(maThumbRect);
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_THUMB_DOWN)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState |= ControlState::PRESSED;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (HasFocus())
|
2014-12-30 16:26:11 +02:00
|
|
|
nState |= ControlState::FOCUSED;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
if (IsMouseOver())
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
|
|
|
|
if (pRect)
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (pRect == &maThumbRect)
|
2014-12-30 16:26:11 +02:00
|
|
|
nState |= ControlState::ROLLOVER;
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
|
|
|
|
aCtrlRegion, nState, scrValue, OUString());
|
2004-05-10 14:47:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bNativeOK;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
DecorationView aDecoView(&rRenderContext);
|
|
|
|
Rectangle aTempRect;
|
2015-05-11 12:33:22 +02:00
|
|
|
DrawButtonFlags nStyle;
|
2015-05-07 12:12:34 +09:00
|
|
|
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
|
|
|
|
SymbolType eSymbolType;
|
|
|
|
bool bEnabled = IsEnabled();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Finish some open calculations (if any)
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mbCalcSize)
|
|
|
|
ImplCalc(false);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
//vcl::Window *pWin = NULL;
|
|
|
|
//if (rRenderContext.GetOutDevType() == OUTDEV_WINDOW)
|
|
|
|
// pWin = static_cast<vcl::Window*>(&rRenderContext);
|
2004-05-10 14:47:32 +00:00
|
|
|
|
|
|
|
// Draw the entire control if the native theme engine needs it
|
2015-05-18 15:38:34 +09:00
|
|
|
if (nDrawFlags && rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_DRAW_BACKGROUND_HORZ))
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
ImplDrawNative(rRenderContext, SCRBAR_DRAW_BACKGROUND);
|
2004-05-10 14:47:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_BTN1) && (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN1)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-11 12:33:22 +02:00
|
|
|
nStyle = DrawButtonFlags::NoLightBorder;
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_BTN1_DOWN)
|
2015-05-11 12:33:22 +02:00
|
|
|
nStyle |= DrawButtonFlags::Pressed;
|
2000-09-18 16:07:07 +00:00
|
|
|
aTempRect = aDecoView.DrawButton( maBtn1Rect, nStyle );
|
|
|
|
ImplCalcSymbolRect( aTempRect );
|
2015-05-08 15:21:46 +02:00
|
|
|
DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
|
2015-05-07 12:12:34 +09:00
|
|
|
if ((mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled)
|
2015-05-08 15:21:46 +02:00
|
|
|
nSymbolStyle |= DrawSymbolFlags::Disable;
|
2015-05-20 14:46:54 +02:00
|
|
|
if (rStyleSettings.GetOptions() & StyleSettingsOptions::ScrollArrow)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (GetStyle() & WB_HORZ)
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::ARROW_LEFT;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::ARROW_UP;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (GetStyle() & WB_HORZ)
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::SPIN_LEFT;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::SPIN_UP;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-05-08 15:21:46 +02:00
|
|
|
aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_BTN2) && (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN2)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-11 12:33:22 +02:00
|
|
|
nStyle = DrawButtonFlags::NoLightBorder;
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_BTN2_DOWN)
|
2015-05-11 12:33:22 +02:00
|
|
|
nStyle |= DrawButtonFlags::Pressed;
|
2015-05-07 12:12:34 +09:00
|
|
|
aTempRect = aDecoView.DrawButton(maBtn2Rect, nStyle);
|
|
|
|
ImplCalcSymbolRect(aTempRect);
|
2015-05-08 15:21:46 +02:00
|
|
|
DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE;
|
2015-05-07 12:12:34 +09:00
|
|
|
if ((mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled)
|
2015-05-08 15:21:46 +02:00
|
|
|
nSymbolStyle |= DrawSymbolFlags::Disable;
|
2015-05-20 14:46:54 +02:00
|
|
|
if (rStyleSettings.GetOptions() & StyleSettingsOptions::ScrollArrow)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (GetStyle() & WB_HORZ)
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::ARROW_RIGHT;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::ARROW_DOWN;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (GetStyle() & WB_HORZ)
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::SPIN_RIGHT;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2014-10-14 09:36:33 +02:00
|
|
|
eSymbolType = SymbolType::SPIN_DOWN;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-05-08 15:21:46 +02:00
|
|
|
aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nSymbolStyle);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 12:12:34 +09:00
|
|
|
rRenderContext.SetLineColor();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_THUMB) && (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_THUMB)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (!maThumbRect.IsEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (bEnabled)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-11 12:33:22 +02:00
|
|
|
nStyle = DrawButtonFlags::NoLightBorder;
|
2015-05-07 12:12:34 +09:00
|
|
|
aTempRect = aDecoView.DrawButton(maThumbRect, nStyle);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
|
|
|
|
rRenderContext.DrawRect(maThumbRect);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_PAGE1) && (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE1)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_PAGE1_DOWN)
|
|
|
|
rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2015-05-07 12:12:34 +09:00
|
|
|
rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
|
|
|
|
rRenderContext.DrawRect(maPage1Rect);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-05-18 15:38:34 +09:00
|
|
|
if ((nDrawFlags & SCRBAR_DRAW_PAGE2) && (!ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE2)))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
if (mnStateFlags & SCRBAR_STATE_PAGE2_DOWN)
|
|
|
|
rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2015-05-07 12:12:34 +09:00
|
|
|
rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
|
|
|
|
rRenderContext.DrawRect(maPage2Rect);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
long ScrollBar::ImplScroll( long nNewPos, bool bCallEndScroll )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-19 10:12:18 +00:00
|
|
|
long nOldPos = mnThumbPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
SetThumbPos( nNewPos );
|
2002-07-19 10:12:18 +00:00
|
|
|
long nDelta = mnThumbPos-nOldPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nDelta )
|
|
|
|
{
|
2002-07-19 10:12:18 +00:00
|
|
|
mnDelta = nDelta;
|
|
|
|
Scroll();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bCallEndScroll )
|
|
|
|
EndScroll();
|
|
|
|
mnDelta = 0;
|
|
|
|
}
|
|
|
|
return nDelta;
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
long ScrollBar::ImplDoAction( bool bCallEndScroll )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
long nDelta = 0;
|
|
|
|
|
|
|
|
switch ( meScrollType )
|
|
|
|
{
|
|
|
|
case SCROLL_LINEUP:
|
|
|
|
nDelta = ImplScroll( mnThumbPos-mnLineSize, bCallEndScroll );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_LINEDOWN:
|
|
|
|
nDelta = ImplScroll( mnThumbPos+mnLineSize, bCallEndScroll );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_PAGEUP:
|
|
|
|
nDelta = ImplScroll( mnThumbPos-mnPageSize, bCallEndScroll );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_PAGEDOWN:
|
|
|
|
nDelta = ImplScroll( mnThumbPos+mnPageSize, bCallEndScroll );
|
|
|
|
break;
|
2004-01-06 12:23:57 +00:00
|
|
|
default:
|
2004-02-20 07:50:26 +00:00
|
|
|
;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nDelta;
|
|
|
|
}
|
|
|
|
|
2014-02-21 12:53:51 +01:00
|
|
|
void ScrollBar::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nOldStateFlags = mnStateFlags;
|
2014-02-21 12:53:51 +01:00
|
|
|
bool bAction = false;
|
2015-04-24 12:34:53 +02:00
|
|
|
bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
|
2014-01-22 14:58:57 +01:00
|
|
|
bool bIsInside = false;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
|
|
|
Point aPoint( 0, 0 );
|
2010-07-05 11:20:24 +02:00
|
|
|
Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
switch ( meScrollType )
|
|
|
|
{
|
|
|
|
case SCROLL_LINEUP:
|
2012-10-19 01:21:22 +02:00
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_RIGHT: PART_BUTTON_LEFT): PART_BUTTON_UP,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rMousePos, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn1Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
bAction = bCallAction;
|
|
|
|
mnStateFlags |= SCRBAR_STATE_BTN1_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_BTN1_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_LINEDOWN:
|
2012-10-19 01:21:22 +02:00
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_LEFT: PART_BUTTON_RIGHT): PART_BUTTON_DOWN,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rMousePos, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn2Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
bAction = bCallAction;
|
|
|
|
mnStateFlags |= SCRBAR_STATE_BTN2_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_BTN2_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_PAGEUP:
|
2008-01-14 15:21:43 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_LEFT: PART_TRACK_VERT_UPPER,
|
2010-07-05 11:20:24 +02:00
|
|
|
maPage1Rect, rMousePos, bIsInside )?
|
2008-01-14 15:21:43 +00:00
|
|
|
bIsInside:
|
|
|
|
maPage1Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
bAction = bCallAction;
|
|
|
|
mnStateFlags |= SCRBAR_STATE_PAGE1_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_PAGE1_DOWN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCROLL_PAGEDOWN:
|
2008-01-14 15:21:43 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_RIGHT: PART_TRACK_VERT_LOWER,
|
2010-07-05 11:20:24 +02:00
|
|
|
maPage2Rect, rMousePos, bIsInside )?
|
2008-01-14 15:21:43 +00:00
|
|
|
bIsInside:
|
|
|
|
maPage2Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
bAction = bCallAction;
|
|
|
|
mnStateFlags |= SCRBAR_STATE_PAGE2_DOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mnStateFlags &= ~SCRBAR_STATE_PAGE2_DOWN;
|
|
|
|
break;
|
2004-01-06 12:23:57 +00:00
|
|
|
default:
|
2004-02-20 07:50:26 +00:00
|
|
|
;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( nOldStateFlags != mnStateFlags )
|
2015-05-07 12:12:34 +09:00
|
|
|
Invalidate();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bAction )
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplDoAction( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2005-09-28 13:42:13 +00:00
|
|
|
void ScrollBar::ImplDragThumb( const Point& rMousePos )
|
|
|
|
{
|
|
|
|
long nMovePix;
|
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
nMovePix = rMousePos.X()-(maThumbRect.Left()+mnMouseOff);
|
|
|
|
else
|
|
|
|
nMovePix = rMousePos.Y()-(maThumbRect.Top()+mnMouseOff);
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Move thumb if necessary
|
2005-09-28 13:42:13 +00:00
|
|
|
if ( nMovePix )
|
|
|
|
{
|
|
|
|
mnThumbPixPos += nMovePix;
|
|
|
|
if ( mnThumbPixPos < 0 )
|
|
|
|
mnThumbPixPos = 0;
|
|
|
|
if ( mnThumbPixPos > (mnThumbPixRange-mnThumbPixSize) )
|
|
|
|
mnThumbPixPos = mnThumbPixRange-mnThumbPixSize;
|
|
|
|
long nOldPos = mnThumbPos;
|
|
|
|
mnThumbPos = ImplCalcThumbPos( mnThumbPixPos );
|
|
|
|
ImplUpdateRects();
|
|
|
|
if ( mbFullDrag && (nOldPos != mnThumbPos) )
|
|
|
|
{
|
|
|
|
mnDelta = mnThumbPos-nOldPos;
|
|
|
|
Scroll();
|
|
|
|
mnDelta = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt )
|
|
|
|
{
|
2012-11-06 23:21:06 +00:00
|
|
|
bool bPrimaryWarps = GetSettings().GetStyleSettings().GetPrimaryButtonWarpsSlider();
|
|
|
|
bool bWarp = bPrimaryWarps ? rMEvt.IsLeft() : rMEvt.IsMiddle();
|
|
|
|
bool bPrimaryWarping = bWarp && rMEvt.IsLeft();
|
|
|
|
bool bPage = bPrimaryWarps ? rMEvt.IsRight() : rMEvt.IsLeft();
|
|
|
|
|
|
|
|
if (rMEvt.IsLeft() || rMEvt.IsMiddle() || rMEvt.IsRight())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
const Point& rMousePos = rMEvt.GetPosPixel();
|
2015-05-27 15:09:52 +02:00
|
|
|
StartTrackingFlags nTrackFlags = StartTrackingFlags::NONE;
|
2015-04-24 12:34:53 +02:00
|
|
|
bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
|
2014-01-22 14:58:57 +01:00
|
|
|
bool bIsInside = false;
|
2013-05-16 09:16:53 +09:00
|
|
|
bool bDragToMouse = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-05-10 14:47:32 +00:00
|
|
|
Point aPoint( 0, 0 );
|
2010-07-05 11:20:24 +02:00
|
|
|
Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2012-10-19 01:21:22 +02:00
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_RIGHT: PART_BUTTON_LEFT): PART_BUTTON_UP,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rMousePos, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn1Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-11-06 23:21:06 +00:00
|
|
|
if (rMEvt.IsLeft() && !(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-27 15:09:52 +02:00
|
|
|
nTrackFlags = StartTrackingFlags::ButtonRepeat;
|
2000-09-18 16:07:07 +00:00
|
|
|
meScrollType = SCROLL_LINEUP;
|
|
|
|
mnDragDraw = SCRBAR_DRAW_BTN1;
|
|
|
|
}
|
|
|
|
}
|
2012-10-19 01:21:22 +02:00
|
|
|
else if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_LEFT: PART_BUTTON_RIGHT): PART_BUTTON_DOWN,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rMousePos, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn2Rect.IsInside( rMousePos ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-11-06 23:21:06 +00:00
|
|
|
if (rMEvt.IsLeft() && !(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-27 15:09:52 +02:00
|
|
|
nTrackFlags = StartTrackingFlags::ButtonRepeat;
|
2000-09-18 16:07:07 +00:00
|
|
|
meScrollType = SCROLL_LINEDOWN;
|
|
|
|
mnDragDraw = SCRBAR_DRAW_BTN2;
|
|
|
|
}
|
|
|
|
}
|
2008-03-05 16:08:17 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2008-03-05 16:08:17 +00:00
|
|
|
bool bThumbHit = HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_THUMB_HORZ : PART_THUMB_VERT,
|
2010-07-05 11:20:24 +02:00
|
|
|
maThumbRect, rMousePos, bIsInside )
|
2008-03-05 16:08:17 +00:00
|
|
|
? bIsInside : maThumbRect.IsInside( rMousePos );
|
2012-11-06 23:21:06 +00:00
|
|
|
|
|
|
|
bool bThumbAction = bWarp || bPage;
|
|
|
|
|
|
|
|
bool bDragHandling = bWarp || (bThumbHit && bThumbAction);
|
2008-03-05 16:08:17 +00:00
|
|
|
if( bDragHandling )
|
2003-12-11 10:52:30 +00:00
|
|
|
{
|
2008-03-05 16:08:17 +00:00
|
|
|
if( mpData )
|
|
|
|
{
|
2013-05-16 09:16:53 +09:00
|
|
|
mpData->mbHide = true; // disable focus blinking
|
2015-05-07 12:12:34 +09:00
|
|
|
if (HasFocus())
|
|
|
|
{
|
|
|
|
mnStateFlags |= SCRBAR_DRAW_THUMB; // paint without focus
|
|
|
|
Invalidate();
|
|
|
|
}
|
2008-03-05 16:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mnVisibleSize < mnMaxRange-mnMinRange )
|
|
|
|
{
|
2015-05-27 15:09:52 +02:00
|
|
|
nTrackFlags = StartTrackingFlags::NONE;
|
2008-03-05 16:08:17 +00:00
|
|
|
meScrollType = SCROLL_DRAG;
|
|
|
|
mnDragDraw = SCRBAR_DRAW_THUMB;
|
2003-12-11 10:52:30 +00:00
|
|
|
|
2008-03-05 16:08:17 +00:00
|
|
|
// calculate mouse offset
|
2012-11-06 23:21:06 +00:00
|
|
|
if (bWarp && (!bThumbHit || !bPrimaryWarping))
|
2008-03-05 16:08:17 +00:00
|
|
|
{
|
2013-05-16 09:16:53 +09:00
|
|
|
bDragToMouse = true;
|
2008-03-05 16:08:17 +00:00
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
mnMouseOff = maThumbRect.GetWidth()/2;
|
|
|
|
else
|
|
|
|
mnMouseOff = maThumbRect.GetHeight()/2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( GetStyle() & WB_HORZ )
|
|
|
|
mnMouseOff = rMousePos.X()-maThumbRect.Left();
|
|
|
|
else
|
|
|
|
mnMouseOff = rMousePos.Y()-maThumbRect.Top();
|
|
|
|
}
|
|
|
|
|
|
|
|
mnStateFlags |= SCRBAR_STATE_THUMB_DOWN;
|
2015-05-07 12:12:34 +09:00
|
|
|
Invalidate();
|
2008-03-05 16:08:17 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-24 12:34:53 +02:00
|
|
|
else if(bPage && (!HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA,
|
|
|
|
aControlRegion, rMousePos, bIsInside ) ||
|
|
|
|
bIsInside) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-27 15:09:52 +02:00
|
|
|
nTrackFlags = StartTrackingFlags::ButtonRepeat;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-03-05 16:08:17 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
if ( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER,
|
2010-07-05 11:20:24 +02:00
|
|
|
maPage1Rect, rMousePos, bIsInside )?
|
2008-03-05 16:08:17 +00:00
|
|
|
bIsInside:
|
|
|
|
maPage1Rect.IsInside( rMousePos ) )
|
2005-09-28 13:42:13 +00:00
|
|
|
{
|
2008-03-05 16:08:17 +00:00
|
|
|
meScrollType = SCROLL_PAGEUP;
|
|
|
|
mnDragDraw = SCRBAR_DRAW_PAGE1;
|
2005-09-28 13:42:13 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2005-09-28 13:42:13 +00:00
|
|
|
{
|
2008-03-05 16:08:17 +00:00
|
|
|
meScrollType = SCROLL_PAGEDOWN;
|
|
|
|
mnDragDraw = SCRBAR_DRAW_PAGE2;
|
2005-09-28 13:42:13 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Should we start Tracking?
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( meScrollType != SCROLL_DONTKNOW )
|
|
|
|
{
|
2013-03-24 10:28:49 -04:00
|
|
|
// store original position for cancel and EndScroll delta
|
2000-09-18 16:07:07 +00:00
|
|
|
mnStartPos = mnThumbPos;
|
2001-10-25 11:40:17 +00:00
|
|
|
// #92906# Call StartTracking() before ImplDoMouseAction(), otherwise
|
|
|
|
// MouseButtonUp() / EndTracking() may be called if somebody is spending
|
|
|
|
// a lot of time in the scroll handler
|
2000-09-18 16:07:07 +00:00
|
|
|
StartTracking( nTrackFlags );
|
2001-10-25 11:40:17 +00:00
|
|
|
ImplDoMouseAction( rMousePos );
|
2005-09-28 13:42:13 +00:00
|
|
|
|
|
|
|
if( bDragToMouse )
|
|
|
|
ImplDragThumb( rMousePos );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::Tracking( const TrackingEvent& rTEvt )
|
|
|
|
{
|
|
|
|
if ( rTEvt.IsTrackingEnded() )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// Restore Button and PageRect status
|
2010-09-29 15:46:40 +08:00
|
|
|
sal_uInt16 nOldStateFlags = mnStateFlags;
|
2000-09-18 16:07:07 +00:00
|
|
|
mnStateFlags &= ~(SCRBAR_STATE_BTN1_DOWN | SCRBAR_STATE_BTN2_DOWN |
|
|
|
|
SCRBAR_STATE_PAGE1_DOWN | SCRBAR_STATE_PAGE2_DOWN |
|
|
|
|
SCRBAR_STATE_THUMB_DOWN);
|
|
|
|
if ( nOldStateFlags != mnStateFlags )
|
2015-05-07 12:12:34 +09:00
|
|
|
Invalidate();
|
2000-09-18 16:07:07 +00:00
|
|
|
mnDragDraw = 0;
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Restore the old ThumbPosition when canceled
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( rTEvt.IsTrackingCanceled() )
|
|
|
|
{
|
2002-07-19 10:12:18 +00:00
|
|
|
long nOldPos = mnThumbPos;
|
2000-09-18 16:07:07 +00:00
|
|
|
SetThumbPos( mnStartPos );
|
2002-07-19 10:12:18 +00:00
|
|
|
mnDelta = mnThumbPos-nOldPos;
|
|
|
|
Scroll();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( meScrollType == SCROLL_DRAG )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// On a SCROLLDRAG we recalculate the Thumb, so that it's back to a
|
|
|
|
// rounded ThumbPosition
|
2000-09-18 16:07:07 +00:00
|
|
|
ImplCalc();
|
|
|
|
|
|
|
|
if ( !mbFullDrag && (mnStartPos != mnThumbPos) )
|
|
|
|
{
|
|
|
|
mnDelta = mnThumbPos-mnStartPos;
|
|
|
|
Scroll();
|
|
|
|
mnDelta = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mnDelta = mnThumbPos-mnStartPos;
|
|
|
|
EndScroll();
|
|
|
|
mnDelta = 0;
|
|
|
|
meScrollType = SCROLL_DONTKNOW;
|
2003-12-11 10:52:30 +00:00
|
|
|
|
|
|
|
if( mpData )
|
2013-05-16 09:16:53 +09:00
|
|
|
mpData->mbHide = false; // re-enable focus blinking
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const Point rMousePos = rTEvt.GetMouseEvent().GetPosPixel();
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Dragging is treated in a special way
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( meScrollType == SCROLL_DRAG )
|
2005-09-28 13:42:13 +00:00
|
|
|
ImplDragThumb( rMousePos );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
ImplDoMouseAction( rMousePos, rTEvt.IsTrackingRepeat() );
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// If ScrollBar values are translated in a way that there's
|
|
|
|
// nothing left to track, we cancel here
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !IsVisible() || (mnVisibleSize >= (mnMaxRange-mnMinRange)) )
|
|
|
|
EndTracking();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
if ( !rKEvt.GetKeyCode().GetModifier() )
|
|
|
|
{
|
|
|
|
switch ( rKEvt.GetKeyCode().GetCode() )
|
|
|
|
{
|
|
|
|
case KEY_HOME:
|
|
|
|
DoScroll( 0 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_END:
|
|
|
|
DoScroll( GetRangeMax() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_LEFT:
|
|
|
|
case KEY_UP:
|
|
|
|
DoScrollAction( SCROLL_LINEUP );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_RIGHT:
|
|
|
|
case KEY_DOWN:
|
|
|
|
DoScrollAction( SCROLL_LINEDOWN );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_PAGEUP:
|
|
|
|
DoScrollAction( SCROLL_PAGEUP );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case KEY_PAGEDOWN:
|
|
|
|
DoScrollAction( SCROLL_PAGEDOWN );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Control::KeyInput( rKEvt );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Control::KeyInput( rKEvt );
|
|
|
|
}
|
|
|
|
|
2015-05-20 18:14:08 +09:00
|
|
|
void ScrollBar::ApplySettings(vcl::RenderContext& rRenderContext)
|
|
|
|
{
|
|
|
|
rRenderContext.SetBackground();
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:34 +09:00
|
|
|
void ScrollBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-07 12:12:34 +09:00
|
|
|
ImplDraw(rRenderContext, SCRBAR_DRAW_ALL);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::Resize()
|
|
|
|
{
|
2002-05-08 15:05:42 +00:00
|
|
|
Control::Resize();
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = true;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( IsReallyVisible() )
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplCalc( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
|
2015-05-04 17:28:40 +02:00
|
|
|
IMPL_LINK_NOARG_TYPED(ScrollBar, ImplAutoTimerHdl, Timer *, void)
|
2003-12-11 10:52:30 +00:00
|
|
|
{
|
|
|
|
if( mpData && mpData->mbHide )
|
2015-05-04 17:28:40 +02:00
|
|
|
return;
|
2003-12-11 10:52:30 +00:00
|
|
|
ImplInvert();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::ImplInvert()
|
|
|
|
{
|
|
|
|
Rectangle aRect( maThumbRect );
|
|
|
|
if( aRect.getWidth() > 4 )
|
|
|
|
{
|
|
|
|
aRect.Left() += 2;
|
|
|
|
aRect.Right() -= 2;
|
|
|
|
}
|
|
|
|
if( aRect.getHeight() > 4 )
|
|
|
|
{
|
|
|
|
aRect.Top() += 2;
|
|
|
|
aRect.Bottom() -= 2;
|
|
|
|
}
|
|
|
|
|
2015-05-27 16:01:34 +02:00
|
|
|
Invert( aRect );
|
2003-12-11 10:52:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::GetFocus()
|
|
|
|
{
|
|
|
|
if( !mpData )
|
|
|
|
{
|
|
|
|
mpData = new ImplScrollBarData;
|
|
|
|
mpData->maTimer.SetTimeoutHdl( LINK( this, ScrollBar, ImplAutoTimerHdl ) );
|
2013-05-16 09:16:53 +09:00
|
|
|
mpData->mbHide = false;
|
2003-12-11 10:52:30 +00:00
|
|
|
}
|
2013-03-22 20:47:21 +01:00
|
|
|
ImplInvert(); // react immediately
|
2003-12-11 10:52:30 +00:00
|
|
|
mpData->maTimer.SetTimeout( GetSettings().GetStyleSettings().GetCursorBlinkTime() );
|
|
|
|
mpData->maTimer.Start();
|
|
|
|
Control::GetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::LoseFocus()
|
|
|
|
{
|
|
|
|
if( mpData )
|
|
|
|
mpData->maTimer.Stop();
|
2015-05-07 12:12:34 +09:00
|
|
|
Invalidate();
|
2003-12-11 10:52:30 +00:00
|
|
|
|
|
|
|
Control::LoseFocus();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScrollBar::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Control::StateChanged( nType );
|
|
|
|
|
2015-05-05 13:46:44 +02:00
|
|
|
if ( nType == StateChangedType::InitShow )
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplCalc( false );
|
2015-05-05 13:46:44 +02:00
|
|
|
else if ( nType == StateChangedType::Data )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplCalc( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-05-05 13:46:44 +02:00
|
|
|
else if ( nType == StateChangedType::UpdateMode )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
ImplCalc( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 13:46:44 +02:00
|
|
|
else if ( nType == StateChangedType::Enable )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
Invalidate();
|
|
|
|
}
|
2015-05-05 13:46:44 +02:00
|
|
|
else if ( nType == StateChangedType::Style )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplInitStyle( GetStyle() );
|
|
|
|
if ( IsReallyVisible() && IsUpdateMode() )
|
|
|
|
{
|
|
|
|
if ( (GetPrevStyle() & SCRBAR_VIEW_STYLE) !=
|
|
|
|
(GetStyle() & SCRBAR_VIEW_STYLE) )
|
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = true;
|
|
|
|
ImplCalc( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Control::DataChanged( rDCEvt );
|
|
|
|
|
2015-01-09 16:29:43 +02:00
|
|
|
if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
|
2015-01-12 12:55:32 +02:00
|
|
|
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
|
2004-09-08 14:55:40 +00:00
|
|
|
{
|
2014-02-21 12:53:51 +01:00
|
|
|
mbCalcSize = true;
|
|
|
|
ImplCalc( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
Invalidate();
|
2004-09-08 14:55:40 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-05-10 14:47:32 +00:00
|
|
|
Rectangle* ScrollBar::ImplFindPartRect( const Point& rPt )
|
|
|
|
{
|
2015-04-24 12:34:53 +02:00
|
|
|
bool bHorizontal = ( GetStyle() & WB_HORZ ) != 0;
|
2014-01-22 14:58:57 +01:00
|
|
|
bool bIsInside = false;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
|
|
|
Point aPoint( 0, 0 );
|
2010-07-05 11:20:24 +02:00
|
|
|
Rectangle aControlRegion( aPoint, GetOutputSizePixel() );
|
2004-05-10 14:47:32 +00:00
|
|
|
|
2012-10-19 01:21:22 +02:00
|
|
|
if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_RIGHT: PART_BUTTON_LEFT): PART_BUTTON_UP,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rPt, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn1Rect.IsInside( rPt ) )
|
|
|
|
return &maBtn1Rect;
|
2012-10-19 01:21:22 +02:00
|
|
|
else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? (IsRTLEnabled()? PART_BUTTON_LEFT: PART_BUTTON_RIGHT): PART_BUTTON_DOWN,
|
2004-05-10 14:47:32 +00:00
|
|
|
aControlRegion, rPt, bIsInside )?
|
|
|
|
bIsInside:
|
|
|
|
maBtn2Rect.IsInside( rPt ) )
|
|
|
|
return &maBtn2Rect;
|
2008-01-14 15:21:43 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER,
|
2010-07-05 11:20:24 +02:00
|
|
|
maPage1Rect, rPt, bIsInside)?
|
2008-01-14 15:21:43 +00:00
|
|
|
bIsInside:
|
|
|
|
maPage1Rect.IsInside( rPt ) )
|
2004-05-10 14:47:32 +00:00
|
|
|
return &maPage1Rect;
|
2008-01-14 15:21:43 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER,
|
2010-07-05 11:20:24 +02:00
|
|
|
maPage2Rect, rPt, bIsInside)?
|
2008-01-14 15:21:43 +00:00
|
|
|
bIsInside:
|
|
|
|
maPage2Rect.IsInside( rPt ) )
|
2004-05-10 14:47:32 +00:00
|
|
|
return &maPage2Rect;
|
2008-01-14 15:21:43 +00:00
|
|
|
// HitTestNativeControl, see remark at top of file
|
|
|
|
else if( HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal ? PART_THUMB_HORZ : PART_THUMB_VERT,
|
2010-07-05 11:20:24 +02:00
|
|
|
maThumbRect, rPt, bIsInside)?
|
2008-01-14 15:21:43 +00:00
|
|
|
bIsInside:
|
|
|
|
maThumbRect.IsInside( rPt ) )
|
2004-05-10 14:47:32 +00:00
|
|
|
return &maThumbRect;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-01-18 00:18:52 +01:00
|
|
|
bool ScrollBar::PreNotify( NotifyEvent& rNEvt )
|
2004-02-20 07:50:26 +00:00
|
|
|
{
|
2004-05-10 14:47:32 +00:00
|
|
|
const MouseEvent* pMouseEvt = NULL;
|
|
|
|
|
2014-11-26 14:53:25 +00:00
|
|
|
if( (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != NULL )
|
2004-05-10 14:47:32 +00:00
|
|
|
{
|
|
|
|
if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// Trigger a redraw if mouse over state has changed
|
2004-05-10 14:47:32 +00:00
|
|
|
if( IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL) )
|
|
|
|
{
|
|
|
|
Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
|
|
|
|
Rectangle* pLastRect = ImplFindPartRect( GetLastPointerPosPixel() );
|
|
|
|
if( pRect != pLastRect || pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow() )
|
|
|
|
{
|
2014-09-27 14:52:40 +02:00
|
|
|
vcl::Region aRgn( GetActiveClipRegion() );
|
|
|
|
vcl::Region aClipRegion;
|
2004-05-10 14:47:32 +00:00
|
|
|
|
|
|
|
if ( pRect )
|
|
|
|
aClipRegion.Union( *pRect );
|
|
|
|
if ( pLastRect )
|
|
|
|
aClipRegion.Union( *pLastRect );
|
|
|
|
|
|
|
|
// Support for 3-button scroll bars
|
2014-02-21 12:53:51 +01:00
|
|
|
bool bHas3Buttons = IsNativeControlSupported( CTRL_SCROLLBAR, HAS_THREE_BUTTONS );
|
2004-05-10 14:47:32 +00:00
|
|
|
if ( bHas3Buttons && ( pRect == &maBtn1Rect || pLastRect == &maBtn1Rect ) )
|
|
|
|
{
|
|
|
|
aClipRegion.Union( maBtn2Rect );
|
|
|
|
}
|
|
|
|
|
|
|
|
SetClipRegion( aClipRegion );
|
2015-04-28 12:53:27 +09:00
|
|
|
Invalidate(aClipRegion.GetBoundRect());
|
2004-05-10 14:47:32 +00:00
|
|
|
|
|
|
|
SetClipRegion( aRgn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-25 20:46:49 +00:00
|
|
|
return Control::PreNotify(rNEvt);
|
2004-02-20 07:50:26 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScrollBar::Scroll()
|
|
|
|
{
|
2004-10-22 11:13:38 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_SCROLL, maScrollHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::EndScroll()
|
|
|
|
{
|
2004-10-22 11:13:38 +00:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_SCROLLBAR_ENDSCROLL, maEndScrollHdl, this );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long ScrollBar::DoScroll( long nNewPos )
|
|
|
|
{
|
|
|
|
if ( meScrollType != SCROLL_DONTKNOW )
|
|
|
|
return 0;
|
|
|
|
|
2013-03-07 21:34:44 +02:00
|
|
|
SAL_INFO("vcl.scrollbar", "DoScroll(" << nNewPos << ")");
|
2000-09-18 16:07:07 +00:00
|
|
|
meScrollType = SCROLL_DRAG;
|
2014-02-21 12:53:51 +01:00
|
|
|
long nDelta = ImplScroll( nNewPos, true );
|
2000-09-18 16:07:07 +00:00
|
|
|
meScrollType = SCROLL_DONTKNOW;
|
|
|
|
return nDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
long ScrollBar::DoScrollAction( ScrollType eScrollType )
|
|
|
|
{
|
|
|
|
if ( (meScrollType != SCROLL_DONTKNOW) ||
|
|
|
|
(eScrollType == SCROLL_DONTKNOW) ||
|
|
|
|
(eScrollType == SCROLL_DRAG) )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
meScrollType = eScrollType;
|
2014-02-21 12:53:51 +01:00
|
|
|
long nDelta = ImplDoAction( true );
|
2000-09-18 16:07:07 +00:00
|
|
|
meScrollType = SCROLL_DONTKNOW;
|
|
|
|
return nDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::SetRangeMin( long nNewRange )
|
|
|
|
{
|
|
|
|
SetRange( Range( nNewRange, GetRangeMax() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::SetRangeMax( long nNewRange )
|
|
|
|
{
|
|
|
|
SetRange( Range( GetRangeMin(), nNewRange ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::SetRange( const Range& rRange )
|
|
|
|
{
|
2013-03-22 20:47:21 +01:00
|
|
|
// Adapt Range
|
2000-09-18 16:07:07 +00:00
|
|
|
Range aRange = rRange;
|
|
|
|
aRange.Justify();
|
|
|
|
long nNewMinRange = aRange.Min();
|
|
|
|
long nNewMaxRange = aRange.Max();
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// If Range differs, set a new one
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( (mnMinRange != nNewMinRange) ||
|
|
|
|
(mnMaxRange != nNewMaxRange) )
|
|
|
|
{
|
|
|
|
mnMinRange = nNewMinRange;
|
|
|
|
mnMaxRange = nNewMaxRange;
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Adapt Thumb
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mnThumbPos > mnMaxRange-mnVisibleSize )
|
|
|
|
mnThumbPos = mnMaxRange-mnVisibleSize;
|
|
|
|
if ( mnThumbPos < mnMinRange )
|
|
|
|
mnThumbPos = mnMinRange;
|
|
|
|
|
2015-05-23 19:44:15 +01:00
|
|
|
CompatStateChanged( StateChangedType::Data );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::SetThumbPos( long nNewThumbPos )
|
|
|
|
{
|
|
|
|
if ( nNewThumbPos > mnMaxRange-mnVisibleSize )
|
|
|
|
nNewThumbPos = mnMaxRange-mnVisibleSize;
|
|
|
|
if ( nNewThumbPos < mnMinRange )
|
|
|
|
nNewThumbPos = mnMinRange;
|
|
|
|
|
|
|
|
if ( mnThumbPos != nNewThumbPos )
|
|
|
|
{
|
|
|
|
mnThumbPos = nNewThumbPos;
|
2015-05-23 19:44:15 +01:00
|
|
|
CompatStateChanged( StateChangedType::Data );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::SetVisibleSize( long nNewSize )
|
|
|
|
{
|
|
|
|
if ( mnVisibleSize != nNewSize )
|
|
|
|
{
|
|
|
|
mnVisibleSize = nNewSize;
|
|
|
|
|
2013-03-22 20:47:21 +01:00
|
|
|
// Adapt Thumb
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( mnThumbPos > mnMaxRange-mnVisibleSize )
|
|
|
|
mnThumbPos = mnMaxRange-mnVisibleSize;
|
|
|
|
if ( mnThumbPos < mnMinRange )
|
|
|
|
mnThumbPos = mnMinRange;
|
2015-05-23 19:44:15 +01:00
|
|
|
CompatStateChanged( StateChangedType::Data );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-14 10:40:11 +00:00
|
|
|
Size ScrollBar::GetOptimalSize() const
|
2012-12-04 16:16:14 +00:00
|
|
|
{
|
|
|
|
if (mbCalcSize)
|
2014-02-21 12:53:51 +01:00
|
|
|
const_cast<ScrollBar*>(this)->ImplCalc(false);
|
2013-07-19 10:56:40 +01:00
|
|
|
|
|
|
|
Size aRet = getCurrentCalcSize();
|
|
|
|
|
|
|
|
const long nMinThumbSize = GetSettings().GetStyleSettings().GetMinThumbSize();
|
|
|
|
|
|
|
|
if (GetStyle() & WB_HORZ)
|
|
|
|
{
|
|
|
|
aRet.Width() = maBtn1Rect.GetWidth() + nMinThumbSize + maBtn2Rect.GetWidth();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aRet.Height() = maBtn1Rect.GetHeight() + nMinThumbSize + maBtn2Rect.GetHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
return aRet;
|
2012-12-04 16:16:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Size ScrollBar::getCurrentCalcSize() const
|
2012-10-08 15:40:34 +01:00
|
|
|
{
|
|
|
|
Rectangle aCtrlRegion;
|
|
|
|
aCtrlRegion.Union(maBtn1Rect);
|
|
|
|
aCtrlRegion.Union(maBtn2Rect);
|
|
|
|
aCtrlRegion.Union(maPage1Rect);
|
|
|
|
aCtrlRegion.Union(maPage2Rect);
|
|
|
|
aCtrlRegion.Union(maThumbRect);
|
|
|
|
return aCtrlRegion.GetSize();
|
|
|
|
}
|
|
|
|
|
2015-05-20 18:14:08 +09:00
|
|
|
void ScrollBarBox::ImplInit(vcl::Window* pParent, WinBits nStyle)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Window::ImplInit( pParent, nStyle, NULL );
|
|
|
|
|
|
|
|
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
|
|
|
|
long nScrollSize = rStyleSettings.GetScrollBarSize();
|
2015-05-20 18:14:08 +09:00
|
|
|
SetSizePixel(Size(nScrollSize, nScrollSize));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ScrollBarBox::ScrollBarBox( vcl::Window* pParent, WinBits nStyle ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
Window( WINDOW_SCROLLBARBOX )
|
|
|
|
{
|
|
|
|
ImplInit( pParent, nStyle );
|
|
|
|
}
|
|
|
|
|
2015-05-20 18:14:08 +09:00
|
|
|
void ScrollBarBox::ApplySettings(vcl::RenderContext& rRenderContext)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-20 18:14:08 +09:00
|
|
|
if (rRenderContext.IsBackground())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-05-20 18:14:08 +09:00
|
|
|
Color aColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
|
|
|
|
ApplyControlBackground(rRenderContext, aColor);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBarBox::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
Window::StateChanged( nType );
|
|
|
|
|
2015-05-20 18:14:08 +09:00
|
|
|
if (nType == StateChangedType::ControlBackground)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBarBox::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
Window::DataChanged( rDCEvt );
|
|
|
|
|
2015-05-20 18:14:08 +09:00
|
|
|
if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
|
|
|
|
(rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|