1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "taskpane/ScrollPanel.hxx"
23 #include "taskpane/ControlContainer.hxx"
24 #include "TaskPaneFocusManager.hxx"
25 #include "taskpane/TitledControl.hxx"
26 #include "AccessibleScrollPanel.hxx"
28 #include <vcl/svapp.hxx>
29 #include <svtools/valueset.hxx>
31 namespace sd
{ namespace toolpanel
{
33 ScrollPanel::ScrollPanel (
34 ::Window
& i_rParentWindow
)
35 : Control (&i_rParentWindow
, WB_DIALOGCONTROL
),
37 maScrollWindow(this, WB_DIALOGCONTROL
),
38 maVerticalScrollBar(this, WB_VERT
),
39 maHorizontalScrollBar(this, WB_HORZ
),
40 maScrollBarFiller(this),
41 maScrollWindowFiller(&maScrollWindow
),
42 mbIsRearrangePending(true),
43 mbIsLayoutPending(true),
52 void ScrollPanel::Construct()
54 SetAccessibleName (OUString("Sub Task Panel"));
55 mpControlContainer
->SetMultiSelection (true);
57 SetBorderStyle (WINDOW_BORDER_NORMAL
);
58 SetMapMode (MapMode(MAP_PIXEL
));
60 // To reduce flickering during repaints make the container windows
61 // transparent and rely on their children to paint the whole area.
62 SetBackground(Wallpaper());
63 maScrollWindow
.SetBackground(Wallpaper());
64 maScrollWindowFiller
.SetBackground(
65 Application::GetSettings().GetStyleSettings().GetWindowColor());
67 maScrollWindow
.Show();
69 // Initialize the scroll bars.
70 maVerticalScrollBar
.SetScrollHdl (
71 LINK(this, ScrollPanel
, ScrollBarHandler
));
72 maVerticalScrollBar
.EnableDrag (sal_True
);
73 maHorizontalScrollBar
.SetScrollHdl (
74 LINK(this, ScrollPanel
, ScrollBarHandler
));
75 maHorizontalScrollBar
.EnableDrag (sal_True
);
81 ScrollPanel::~ScrollPanel (void)
83 sal_uInt32 nCount
= mpControlContainer
->GetControlCount();
84 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; nIndex
++)
86 TreeNode
* pNode
= mpControlContainer
->GetControl(nIndex
);
87 TreeNode
* pControl
= pNode
;
88 // When the node has been created as TitledControl then use its
89 // control instead of pNode directly.
90 TitledControl
* pTitledControl
= dynamic_cast<TitledControl
*>(pNode
);
91 if (pTitledControl
!= NULL
)
92 pControl
= pTitledControl
->GetControl();
94 // Remove this object as listener from the control.
95 if (pControl
!= NULL
&& pControl
->GetWindow()!=NULL
)
97 pControl
->GetWindow()->RemoveEventListener(
98 LINK(this,ScrollPanel
,WindowEventListener
));
101 mpControlContainer
->DeleteChildren();
106 SAL_WNODEPRECATED_DECLARATIONS_PUSH
107 TitledControl
* ScrollPanel::AddControl (
108 ::std::auto_ptr
<TreeNode
> pControl
,
109 const String
& rTitle
,
110 const OString
& rHelpId
)
112 // We are interested only in the title. The control itself is
113 // managed by the content object.
114 TitledControl
* pTitledControl
= new TitledControl(
118 TitledControlStandardClickHandler(GetControlContainer(), ControlContainer::ES_TOGGLE
),
119 TitleBar::TBT_SUB_CONTROL_HEADLINE
);
120 pTitledControl
->GetTitleBar()->SetHelpId(rHelpId
);
122 AddControl(::std::auto_ptr
<TreeNode
>(pTitledControl
));
124 return pTitledControl
;
126 SAL_WNODEPRECATED_DECLARATIONS_POP
129 SAL_WNODEPRECATED_DECLARATIONS_PUSH
130 void ScrollPanel::AddControl (::std::auto_ptr
<TreeNode
> pControl
)
132 if (pControl
.get() != NULL
)
134 // Add a window event listener which does two things:
135 // 1. Listen for controls being shown or hidden so that the layout
137 // 2. Track selection changes in order to make the selected elements
139 const Link
aWindowListener(LINK(this,ScrollPanel
,WindowEventListener
));
140 OSL_ASSERT(pControl
->GetWindow()!=NULL
);
141 pControl
->GetWindow()->AddEventListener(aWindowListener
);
143 TitledControl
* pTitledControl
= dynamic_cast<TitledControl
*>(pControl
.get());
144 if (pTitledControl
!= NULL
)
146 OSL_ASSERT(pTitledControl
->GetControl()!=NULL
);
147 OSL_ASSERT(pTitledControl
->GetControl()->GetWindow()!=NULL
);
148 pTitledControl
->GetControl()->GetWindow()->AddEventListener(aWindowListener
);
151 FocusManager
& rFocusManager (FocusManager::Instance());
152 int nControlCount (mpControlContainer
->GetControlCount());
153 // Replace the old links for cycling between first and last child by
155 if (nControlCount
> 0)
157 ::Window
* pFirst
= mpControlContainer
->GetControl(0)->GetWindow();
158 ::Window
* pLast
= mpControlContainer
->GetControl(nControlCount
-1)->GetWindow();
159 rFocusManager
.RemoveLinks(pFirst
,pLast
);
160 rFocusManager
.RemoveLinks(pLast
,pFirst
);
162 rFocusManager
.RegisterLink(pFirst
,pControl
->GetWindow(), KEY_UP
);
163 rFocusManager
.RegisterLink(pControl
->GetWindow(),pFirst
, KEY_DOWN
);
167 // Add a down link only for the first control so that when entering
168 // the sub tool panel the focus is set to the first control.
169 if (nControlCount
== 0)
170 rFocusManager
.RegisterDownLink(GetParent(), pControl
->GetWindow());
171 rFocusManager
.RegisterUpLink(pControl
->GetWindow(), GetParent());
173 pControl
->GetWindow()->SetParent(&maScrollWindow
);
174 mpControlContainer
->AddControl (pControl
);
175 mpControlContainer
->SetExpansionState(
176 mpControlContainer
->GetControlCount()-1,
177 ControlContainer::ES_EXPAND
);
180 SAL_WNODEPRECATED_DECLARATIONS_POP
184 void ScrollPanel::Paint (const Rectangle
& rRect
)
186 if (mbIsRearrangePending
)
188 if (mbIsLayoutPending
)
190 ::Window::Paint (rRect
);
192 // Paint the outer border and the space between every two children.
193 Color
aOriginalLineColor (maScrollWindow
.GetLineColor());
194 Color
aOriginalFillColor (maScrollWindow
.GetFillColor());
196 maScrollWindow
.SetLineColor ();
197 maScrollWindow
.SetFillColor (
198 GetSettings().GetStyleSettings().GetWindowColor());
200 Size
aSize (maScrollWindow
.GetOutputSizePixel());
201 // Paint left and right vertical border.
202 Rectangle
aVerticalArea (
204 Size(mnHorizontalBorder
,aSize
.Height()));
205 maScrollWindow
.DrawRect (aVerticalArea
);
206 aVerticalArea
.Right() += mnHorizontalBorder
+ mnChildrenWidth
- 1;
207 aVerticalArea
.Left() = aVerticalArea
.Right() + mnHorizontalBorder
;
208 maScrollWindow
.DrawRect (aVerticalArea
);
210 // Paint horizontal stripes.
211 Rectangle
aStripeArea (
212 Point (mnHorizontalBorder
,0),
213 Size(mnChildrenWidth
,0));
214 StripeList::const_iterator iStripe
;
215 for (iStripe
=maStripeList
.begin(); iStripe
!=maStripeList
.end(); ++iStripe
)
217 aStripeArea
.Top() = iStripe
->first
;
218 aStripeArea
.Bottom() = iStripe
->second
;
219 if (aStripeArea
.Bottom() < 0)
221 if (aStripeArea
.Top() >= aSize
.Height())
223 maScrollWindow
.DrawRect (aStripeArea
);
226 maScrollWindow
.SetLineColor (aOriginalLineColor
);
227 maScrollWindow
.SetFillColor (aOriginalFillColor
);
233 void ScrollPanel::Resize (void)
236 mbIsRearrangePending
= true;
237 mbIsLayoutPending
= true;
243 void ScrollPanel::RequestResize (void)
245 mbIsRearrangePending
= true;
246 mbIsLayoutPending
= true;
253 Size
ScrollPanel::GetPreferredSize (void)
255 return GetRequiredSize();
261 sal_Int32
ScrollPanel::GetPreferredWidth (sal_Int32
)
263 return GetPreferredSize().Width();
269 sal_Int32
ScrollPanel::GetPreferredHeight (sal_Int32
)
271 return GetPreferredSize().Height();
277 bool ScrollPanel::IsResizable (void)
285 ::Window
* ScrollPanel::GetWindow (void)
293 sal_Int32
ScrollPanel::GetMinimumWidth (void)
295 return TreeNode::GetMinimumWidth();
301 void ScrollPanel::ExpandControl (
303 bool bExpansionState
)
305 // Toggle expand status.
306 pControl
->Expand (bExpansionState
);
315 bool ScrollPanel::IsVerticalScrollBarVisible (void) const
317 return maVerticalScrollBar
.IsReallyVisible();
323 bool ScrollPanel::IsHorizontalScrollBarVisible (void) const
325 return maHorizontalScrollBar
.IsReallyVisible();
331 ScrollBar
& ScrollPanel::GetVerticalScrollBar (void)
333 return maVerticalScrollBar
;
339 ScrollBar
& ScrollPanel::GetHorizontalScrollBar (void)
341 return maHorizontalScrollBar
;
347 /** This control shows an expansion bar for every control and in a
348 separate area below that expansion area it shows all controls each
349 with its title bar. When there is not enough space then show a
350 scroll bar in the control area.
352 void ScrollPanel::Rearrange (void)
354 Size
aRequiredSize (GetRequiredSize());
355 if (aRequiredSize
.Width()>0 && aRequiredSize
.Height()>0)
357 Size
aAvailableSize (SetupScrollBars (aRequiredSize
));
358 maScrollWindow
.SetPosSizePixel(
362 // Make the children at least as wide as the sub tool panel.
363 if (aRequiredSize
.Width() < aAvailableSize
.Width())
364 aRequiredSize
.Width() = aAvailableSize
.Width();
365 mnChildrenWidth
= -2*mnHorizontalBorder
;
366 if (maHorizontalScrollBar
.IsVisible())
367 mnChildrenWidth
+= aRequiredSize
.Width();
369 mnChildrenWidth
+= aAvailableSize
.Width();
371 sal_Int32
nChildrenHeight (LayoutChildren());
372 maVerticalScrollBar
.SetRangeMax (
373 nChildrenHeight
+ mnVerticalBorder
);
375 mbIsRearrangePending
= false;
382 Size
ScrollPanel::GetRequiredSize (void)
384 // First determine the width of the children. This is the maximum of
385 // the current window width and the individual minimum widths of the
387 int nChildrenWidth (GetSizePixel().Width());
388 unsigned int nCount
= mpControlContainer
->GetControlCount();
390 for (nIndex
=0; nIndex
<nCount
; nIndex
++)
392 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
393 int nMinimumWidth (pChild
->GetMinimumWidth());
394 if (nMinimumWidth
> nChildrenWidth
)
395 nChildrenWidth
= nMinimumWidth
;
398 // Determine the accumulated width of all children when scaled to the
400 nChildrenWidth
-= 2*mnHorizontalBorder
;
401 Size
aTotalSize (nChildrenWidth
,
402 2*mnVerticalBorder
+ (nCount
-1) * mnVerticalGap
);
403 for (nIndex
=0; nIndex
<nCount
; nIndex
++)
405 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
406 sal_Int32 nHeight
= pChild
->GetPreferredHeight(nChildrenWidth
);
407 aTotalSize
.Height() += nHeight
;
416 sal_Int32
ScrollPanel::LayoutChildren (void)
418 maStripeList
.clear();
420 Point
aPosition (maScrollOffset
);
421 aPosition
.X() += mnHorizontalBorder
;
422 maStripeList
.push_back( ::std::pair
<int,int>(
424 aPosition
.Y() + mnVerticalBorder
- 1));
425 aPosition
.Y() += mnVerticalBorder
;
427 // Place the controls one over the other.
428 unsigned int nCount (mpControlContainer
->GetControlCount());
429 for (unsigned int nIndex
=0; nIndex
<nCount
; nIndex
++)
433 maStripeList
.push_back( ::std::pair
<int,int>(
435 aPosition
.Y() + mnVerticalGap
- 1));
436 aPosition
.Y() += mnVerticalGap
;
438 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
439 int nControlHeight
= pChild
->GetPreferredHeight(mnChildrenWidth
);
440 pChild
->GetWindow()->SetPosSizePixel(
442 Size(mnChildrenWidth
, nControlHeight
));
443 aPosition
.Y() += nControlHeight
;
446 // If the children do not cover their parent window completely
447 // (regarding the height) we put a filler below that is responsible for
448 // painting the remaining space.
449 int nWindowHeight
= maScrollWindow
.GetSizePixel().Height();
450 if (aPosition
.Y() < nWindowHeight
)
452 maScrollWindowFiller
.SetPosSizePixel (
454 Size(mnChildrenWidth
, nWindowHeight
-aPosition
.Y()));
455 maStripeList
.push_back( ::std::pair
<int,int>(
458 // maScrollWindowFiller.Show();
459 aPosition
.Y() = nWindowHeight
;
462 maScrollWindowFiller
.Hide();
464 aPosition
.Y() += mnVerticalBorder
;
465 mbIsLayoutPending
= false;
467 return aPosition
.Y()-maScrollOffset
.Y();
473 Size
ScrollPanel::SetupScrollBars (const Size
& rRequiredSize
)
475 Size
aWindowSize (GetSizePixel());
476 Size
aScrollBarSize (
477 maVerticalScrollBar
.GetSizePixel().Width(),
478 maHorizontalScrollBar
.GetSizePixel().Height());
479 Size
aRemainingSize (aWindowSize
);
481 // Determine which scroll bars have to be shown.
482 bool bShowHorizontal
= false;
483 if (rRequiredSize
.Width() > aWindowSize
.Width())
484 bShowHorizontal
= true;
485 bool bShowVertical
= false;
486 if (rRequiredSize
.Height() > aWindowSize
.Height())
487 bShowVertical
= true;
488 // Showing one scroll bar may reduce the available size so that the
489 // other one has to be shown as well.
490 if (bShowHorizontal
&& ! bShowVertical
)
492 if ((rRequiredSize
.Height() + aScrollBarSize
.Height())
493 > aWindowSize
.Height())
494 bShowVertical
= true;
496 else if (bShowVertical
&& ! bShowHorizontal
)
498 if (GetMinimumWidth() + aScrollBarSize
.Width() > aWindowSize
.Width())
499 bShowHorizontal
= true;
502 // Setup the scroll bars.
503 aRemainingSize
.Width()
504 = SetupVerticalScrollBar (bShowVertical
, rRequiredSize
.Height());
505 aRemainingSize
.Height()
506 = SetupHorizontalScrollBar (bShowHorizontal
, rRequiredSize
.Width());
509 if (bShowHorizontal
&& bShowVertical
)
511 maScrollBarFiller
.SetPosSizePixel (
512 Point(aWindowSize
.Width(), aWindowSize
.Height()),
514 maScrollBarFiller
.Show();
517 maScrollBarFiller
.Hide();
520 return aRemainingSize
;
526 sal_Int32
ScrollPanel::SetupVerticalScrollBar (bool bShow
, sal_Int32 nRange
)
528 Size
aScrollBarSize (
529 maVerticalScrollBar
.GetSizePixel().Width(),
530 maHorizontalScrollBar
.GetSizePixel().Height());
531 Size
aWindowSize (GetOutputSizePixel());
532 sal_Int32
nRemainingWidth (aWindowSize
.Width());
534 // Setup the verical scroll bar.
537 int nWidth
= aScrollBarSize
.Width();
538 int nHeight
= aWindowSize
.Height();
539 maVerticalScrollBar
.SetPosSizePixel(
540 Point(aWindowSize
.Width()-nWidth
,0),
541 Size(nWidth
, nHeight
));
542 maVerticalScrollBar
.Show();
544 // Set the scroll bar range and thumb size.
545 maVerticalScrollBar
.SetRangeMin (0);
546 maVerticalScrollBar
.SetRangeMax (
547 nRange
+ 2*mnVerticalBorder
);
548 maVerticalScrollBar
.SetVisibleSize (aWindowSize
.Height());
549 // Make page size approx. 10% of visible area.
550 maVerticalScrollBar
.SetLineSize (aWindowSize
.Height()/10);
551 // Make page size approx. 100% of visible area.
552 maVerticalScrollBar
.SetPageSize (aWindowSize
.Height());
553 // Make sure that thumb is inside the valid range.
554 maVerticalScrollBar
.SetThumbPos(-maScrollOffset
.Y());
555 long nMinPos
= maVerticalScrollBar
.GetRangeMin();
556 if (maVerticalScrollBar
.GetThumbPos() < nMinPos
)
557 maVerticalScrollBar
.SetThumbPos(nMinPos
);
558 long nMaxPos
= maVerticalScrollBar
.GetRangeMax()
559 - maVerticalScrollBar
.GetVisibleSize();
560 if (maVerticalScrollBar
.GetThumbPos() >= nMaxPos
)
561 maVerticalScrollBar
.SetThumbPos(nMaxPos
);
562 // Set offset to match thumb pos.
563 maScrollOffset
.Y() = -maVerticalScrollBar
.GetThumbPos();
565 nRemainingWidth
-= aScrollBarSize
.Width();
569 maVerticalScrollBar
.Hide();
570 maScrollOffset
.Y() = 0;
573 return nRemainingWidth
;
579 sal_Int32
ScrollPanel::SetupHorizontalScrollBar (bool bShow
, sal_Int32 nRange
)
581 Size
aScrollBarSize (
582 maVerticalScrollBar
.GetSizePixel().Width(),
583 maHorizontalScrollBar
.GetSizePixel().Height());
584 Size
aWindowSize (GetOutputSizePixel());
585 sal_Int32
nRemainingHeight (aWindowSize
.Height());
587 // Setup the horizontal scroll bar.
590 int nHeight
= aScrollBarSize
.Height();
591 int nWidth
= GetOutputSizePixel().Width();
592 maHorizontalScrollBar
.SetPosSizePixel(
593 Point(0, aWindowSize
.Height()-nHeight
),
594 Size(nWidth
,nHeight
));
595 maHorizontalScrollBar
.Show();
597 // Set the scroll bar range and thumb size.
598 maHorizontalScrollBar
.SetRangeMin (0);
599 maHorizontalScrollBar
.SetRangeMax (
600 nRange
+ 2*mnHorizontalBorder
);
601 maHorizontalScrollBar
.SetVisibleSize (aWindowSize
.Width());
602 // Make page size approx. 5% of visible area.
603 maHorizontalScrollBar
.SetLineSize (aWindowSize
.Width()/20+1);
604 // Make page size approx. 50% of visible area.
605 maHorizontalScrollBar
.SetPageSize (aWindowSize
.Width()/2+1);
606 // Make sure that thumb is inside the valid range.
607 maHorizontalScrollBar
.SetThumbPos(-maScrollOffset
.X());
608 long nMinPos
= maHorizontalScrollBar
.GetRangeMin();
609 if (maHorizontalScrollBar
.GetThumbPos() < nMinPos
)
610 maHorizontalScrollBar
.SetThumbPos(nMinPos
);
611 long nMaxPos
= maHorizontalScrollBar
.GetRangeMax()
612 - maHorizontalScrollBar
.GetVisibleSize();
613 if (maHorizontalScrollBar
.GetThumbPos() >= nMaxPos
)
614 maHorizontalScrollBar
.SetThumbPos(nMaxPos
);
615 // Set offset to match thumb pos.
616 maScrollOffset
.X() = -maHorizontalScrollBar
.GetThumbPos();
618 nRemainingHeight
-= aScrollBarSize
.Height();
622 maHorizontalScrollBar
.Hide();
623 maScrollOffset
.X() = 0;
626 return nRemainingHeight
;
630 IMPL_LINK_NOARG(ScrollPanel
, ScrollBarHandler
)
632 maScrollOffset
.X() -= maHorizontalScrollBar
.GetDelta();
633 maScrollOffset
.Y() -= maVerticalScrollBar
.GetDelta();
635 // Scrolling is done by moving the child windows up or down.
636 mbIsLayoutPending
= true;
646 long ScrollPanel::Notify( NotifyEvent
& rNEvt
)
648 long nRet
= sal_False
;
649 if( rNEvt
.GetType() == EVENT_COMMAND
)
651 // note: dynamic_cast is not possible as GetData() returns a void*
652 CommandEvent
* pCmdEvent
= reinterpret_cast< CommandEvent
* >(rNEvt
.GetData());
653 DBG_ASSERT( pCmdEvent
!=0 &&
654 ( pCmdEvent
->IsMouseEvent() == sal_True
||
655 pCmdEvent
->IsMouseEvent() == sal_False
),
656 "Invalid CommandEvent" );
658 switch (pCmdEvent
->GetCommand())
661 case COMMAND_STARTAUTOSCROLL
:
662 case COMMAND_AUTOSCROLL
:
664 nRet
= HandleScrollCommand (*pCmdEvent
, &maHorizontalScrollBar
, &maVerticalScrollBar
);
671 nRet
= ::Window::Notify( rNEvt
);
679 ::com::sun::star::uno::Reference
<
680 ::com::sun::star::accessibility::XAccessible
> ScrollPanel::CreateAccessibleObject (
681 const ::com::sun::star::uno::Reference
<
682 ::com::sun::star::accessibility::XAccessible
>& )
684 return new ::accessibility::AccessibleScrollPanel (
693 void ScrollPanel::MakeRectangleVisible (
694 Rectangle
& aRectangle
,
697 if (maVerticalScrollBar
.IsVisible() && aRectangle
.GetWidth()>0 && aRectangle
.GetHeight()>0)
699 const Rectangle
aRelativeBox (pWindow
->GetWindowExtentsRelative(&maScrollWindow
));
702 -maScrollOffset
.X() + aRelativeBox
.Left(),
703 -maScrollOffset
.Y() + aRelativeBox
.Top());
705 const int nVisibleHeight (maVerticalScrollBar
.GetVisibleSize());
706 const int nVisibleTop (maVerticalScrollBar
.GetThumbPos());
707 if (aRectangle
.Bottom() >= nVisibleTop
+nVisibleHeight
)
708 maVerticalScrollBar
.DoScroll(aRectangle
.Bottom() - nVisibleHeight
);
709 else if (aRectangle
.Top() < nVisibleTop
)
710 maVerticalScrollBar
.DoScroll(aRectangle
.Top());
717 IMPL_LINK(ScrollPanel
,WindowEventListener
,VclSimpleEvent
*,pEvent
)
719 VclWindowEvent
* pWindowEvent
= dynamic_cast<VclWindowEvent
*>(pEvent
);
720 if (pWindowEvent
!= NULL
)
722 switch (pWindowEvent
->GetId())
724 case VCLEVENT_WINDOW_KEYUP
:
725 case VCLEVENT_WINDOW_MOUSEBUTTONUP
:
727 // Make the currently selected item visible.
728 ValueSet
* pControl
= dynamic_cast<ValueSet
*>(pWindowEvent
->GetWindow());
729 if (pControl
!= NULL
)
731 // Get the bounding box of the currently selected item
732 // and enlarge this so that the selection frame is
734 Rectangle
aBox (pControl
->GetItemRect(pControl
->GetSelectItemId()));
738 MakeRectangleVisible(aBox
, pControl
);
743 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN
:
745 // Make the item under the mouse visible. We need this case
746 // for right clicks that open context menus. For these we
747 // only get the mouse down event. The following mouse up
748 // event is sent to the context menu.
749 ValueSet
* pControl
= dynamic_cast<ValueSet
*>(pWindowEvent
->GetWindow());
750 if (pControl
!= NULL
)
752 // Get the bounding box of the item at the mouse
753 // position and enlarge this so that the selection frame
754 // is inside as well.
755 MouseEvent
* pMouseEvent
756 = reinterpret_cast<MouseEvent
*>(pWindowEvent
->GetData());
757 if (pMouseEvent
!= NULL
)
759 Point
aPosition (pMouseEvent
->GetPosPixel());
760 Rectangle
aBox (pControl
->GetItemRect(pControl
->GetItemId(aPosition
)));
764 MakeRectangleVisible(aBox
, pControl
);
771 case VCLEVENT_WINDOW_GETFOCUS
:
773 // Move title bars into the visible area when they get the
774 // focus (::Window wise their enclosing TitledControl gets
776 TitledControl
* pTitledControl
= dynamic_cast<TitledControl
*>(pWindowEvent
->GetWindow());
777 if (pTitledControl
!=NULL
&& pTitledControl
->GetTitleBar()!=NULL
)
779 ::Window
* pTitleBarWindow
= pTitledControl
->GetTitleBar()->GetWindow();
780 Rectangle
aBox(pTitleBarWindow
->GetPosPixel(),pTitleBarWindow
->GetSizePixel());
781 MakeRectangleVisible(
788 case VCLEVENT_WINDOW_SHOW
:
789 case VCLEVENT_WINDOW_HIDE
:
790 case VCLEVENT_WINDOW_ACTIVATE
:
791 case VCLEVENT_WINDOW_RESIZE
:
792 // Rearrange the children of the scroll panel when one of
793 // the children changes its size or visibility.
804 } } // end of namespace ::sd::toolpanel
806 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */