1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScrollPanel.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "taskpane/ScrollPanel.hxx"
36 #include "taskpane/ControlContainer.hxx"
37 #include "TaskPaneFocusManager.hxx"
38 #include "taskpane/TitledControl.hxx"
39 #include "AccessibleScrollPanel.hxx"
41 #include <vcl/svapp.hxx>
42 #include <svtools/valueset.hxx>
44 namespace sd
{ namespace toolpanel
{
46 ScrollPanel::ScrollPanel (
48 : Control (pParent
->GetWindow(), WB_DIALOGCONTROL
),
50 maScrollWindow(this, WB_DIALOGCONTROL
),
51 maVerticalScrollBar(this, WB_VERT
),
52 maHorizontalScrollBar(this, WB_HORZ
),
53 maScrollBarFiller(this),
54 maScrollWindowFiller(&maScrollWindow
),
55 mbIsRearrangePending(true),
56 mbIsLayoutPending(true),
63 ::rtl::OUString::createFromAscii("Sub Task Panel"));
64 mpControlContainer
->SetMultiSelection (true);
66 SetBorderStyle (WINDOW_BORDER_NORMAL
);
67 SetMapMode (MapMode(MAP_PIXEL
));
69 // To reduce flickering during repaints make the container windows
70 // transparent and rely on their children to paint the whole area.
71 SetBackground(Wallpaper());
72 maScrollWindow
.SetBackground(Wallpaper());
73 maScrollWindowFiller
.SetBackground(
74 Application::GetSettings().GetStyleSettings().GetWindowColor());
76 maScrollWindow
.Show();
78 // Initialize the scroll bars.
79 maVerticalScrollBar
.SetScrollHdl (
80 LINK(this, ScrollPanel
, ScrollBarHandler
));
81 maVerticalScrollBar
.EnableDrag (TRUE
);
82 maHorizontalScrollBar
.SetScrollHdl (
83 LINK(this, ScrollPanel
, ScrollBarHandler
));
84 maHorizontalScrollBar
.EnableDrag (TRUE
);
90 ScrollPanel::~ScrollPanel (void)
92 sal_uInt32 nCount
= mpControlContainer
->GetControlCount();
93 for (sal_uInt32 nIndex
=0; nIndex
<nCount
; nIndex
++)
95 TreeNode
* pNode
= mpControlContainer
->GetControl(nIndex
);
96 TreeNode
* pControl
= pNode
;
97 // When the node has been created as TitledControl then use its
98 // control instead of pNode directly.
99 TitledControl
* pTitledControl
= static_cast<TitledControl
*>(pNode
);
100 if (pTitledControl
!= NULL
)
101 pControl
= pTitledControl
->GetControl(false);
103 // Remove this object as listener from the control.
104 if (pControl
!= NULL
&& pControl
->GetWindow()!=NULL
)
106 pControl
->GetWindow()->RemoveEventListener(
107 LINK(this,ScrollPanel
,WindowEventListener
));
110 mpControlContainer
->DeleteChildren();
116 void ScrollPanel::ListHasChanged (void)
118 mpControlContainer
->ListHasChanged ();
125 TitledControl
* ScrollPanel::AddControl (
126 ::std::auto_ptr
<TreeNode
> pControl
,
127 const String
& rTitle
,
130 // We are interested only in the title. The control itself is
131 // managed by the content object.
132 TitledControl
* pTitledControl
= new TitledControl(
136 TitledControlStandardClickHandler(GetControlContainer(), ControlContainer::ES_TOGGLE
),
137 TitleBar::TBT_SUB_CONTROL_HEADLINE
);
138 pTitledControl
->GetTitleBar()->SetHelpId(nHelpId
);
140 AddControl(::std::auto_ptr
<TreeNode
>(pTitledControl
));
142 return pTitledControl
;
148 void ScrollPanel::AddControl (::std::auto_ptr
<TreeNode
> pControl
)
150 if (pControl
.get() != NULL
)
152 // Add a window event listener which does two things:
153 // 1. Listen for controls being shown or hidden so that the layout
155 // 2. Track selection changes in order to make the selected elements
157 const Link
aWindowListener(LINK(this,ScrollPanel
,WindowEventListener
));
158 OSL_ASSERT(pControl
->GetWindow()!=NULL
);
159 pControl
->GetWindow()->AddEventListener(aWindowListener
);
161 TitledControl
* pTitledControl
= dynamic_cast<TitledControl
*>(pControl
.get());
162 if (pTitledControl
!= NULL
)
164 OSL_ASSERT(pTitledControl
->GetControl()!=NULL
);
165 OSL_ASSERT(pTitledControl
->GetControl()->GetWindow()!=NULL
);
166 pTitledControl
->GetControl()->GetWindow()->AddEventListener(aWindowListener
);
169 FocusManager
& rFocusManager (FocusManager::Instance());
170 int nControlCount (mpControlContainer
->GetControlCount());
171 // Replace the old links for cycling between first and last child by
173 if (nControlCount
> 0)
175 ::Window
* pFirst
= mpControlContainer
->GetControl(0)->GetWindow();
176 ::Window
* pLast
= mpControlContainer
->GetControl(nControlCount
-1)->GetWindow();
177 rFocusManager
.RemoveLinks(pFirst
,pLast
);
178 rFocusManager
.RemoveLinks(pLast
,pFirst
);
180 rFocusManager
.RegisterLink(pFirst
,pControl
->GetWindow(), KEY_UP
);
181 rFocusManager
.RegisterLink(pControl
->GetWindow(),pFirst
, KEY_DOWN
);
185 // Add a down link only for the first control so that when entering
186 // the sub tool panel the focus is set to the first control.
187 if (nControlCount
== 0)
188 rFocusManager
.RegisterDownLink(GetParent(), pControl
->GetWindow());
189 rFocusManager
.RegisterUpLink(pControl
->GetWindow(), GetParent());
191 pControl
->GetWindow()->SetParent(&maScrollWindow
);
192 mpControlContainer
->AddControl (pControl
);
193 mpControlContainer
->SetExpansionState(
194 mpControlContainer
->GetControlCount()-1,
195 ControlContainer::ES_EXPAND
);
202 void ScrollPanel::Paint (const Rectangle
& rRect
)
204 if (mbIsRearrangePending
)
206 if (mbIsLayoutPending
)
208 ::Window::Paint (rRect
);
210 // Paint the outer border and the space between every two children.
211 Color
aOriginalLineColor (maScrollWindow
.GetLineColor());
212 Color
aOriginalFillColor (maScrollWindow
.GetFillColor());
214 maScrollWindow
.SetLineColor ();
215 maScrollWindow
.SetFillColor (
216 GetSettings().GetStyleSettings().GetWindowColor());
218 Size
aSize (maScrollWindow
.GetOutputSizePixel());
219 // Paint left and right vertical border.
220 Rectangle
aVerticalArea (
222 Size(mnHorizontalBorder
,aSize
.Height()));
223 maScrollWindow
.DrawRect (aVerticalArea
);
224 aVerticalArea
.Right() += mnHorizontalBorder
+ mnChildrenWidth
- 1;
225 aVerticalArea
.Left() = aVerticalArea
.Right() + mnHorizontalBorder
;
226 maScrollWindow
.DrawRect (aVerticalArea
);
228 // Paint horizontal stripes.
229 Rectangle
aStripeArea (
230 Point (mnHorizontalBorder
,0),
231 Size(mnChildrenWidth
,0));
232 StripeList::const_iterator iStripe
;
233 for (iStripe
=maStripeList
.begin(); iStripe
!=maStripeList
.end(); iStripe
++)
235 aStripeArea
.Top() = iStripe
->first
;
236 aStripeArea
.Bottom() = iStripe
->second
;
237 if (aStripeArea
.Bottom() < 0)
239 if (aStripeArea
.Top() >= aSize
.Height())
241 maScrollWindow
.DrawRect (aStripeArea
);
244 maScrollWindow
.SetLineColor (aOriginalLineColor
);
245 maScrollWindow
.SetFillColor (aOriginalFillColor
);
251 void ScrollPanel::Resize (void)
254 mbIsRearrangePending
= true;
255 mbIsLayoutPending
= true;
261 void ScrollPanel::RequestResize (void)
263 mbIsRearrangePending
= true;
264 mbIsLayoutPending
= true;
271 Size
ScrollPanel::GetPreferredSize (void)
273 return GetRequiredSize();
279 sal_Int32
ScrollPanel::GetPreferredWidth (sal_Int32
)
281 return GetPreferredSize().Width();
287 sal_Int32
ScrollPanel::GetPreferredHeight (sal_Int32
)
289 return GetPreferredSize().Height();
295 bool ScrollPanel::IsResizable (void)
303 ::Window
* ScrollPanel::GetWindow (void)
311 sal_Int32
ScrollPanel::GetMinimumWidth (void)
313 return TreeNode::GetMinimumWidth();
319 void ScrollPanel::ExpandControl (
321 bool bExpansionState
)
323 // Toggle expand status.
324 pControl
->Expand (bExpansionState
);
333 bool ScrollPanel::IsVerticalScrollBarVisible (void) const
335 return maVerticalScrollBar
.IsReallyVisible();
341 bool ScrollPanel::IsHorizontalScrollBarVisible (void) const
343 return maHorizontalScrollBar
.IsReallyVisible();
349 ScrollBar
& ScrollPanel::GetVerticalScrollBar (void)
351 return maVerticalScrollBar
;
357 ScrollBar
& ScrollPanel::GetHorizontalScrollBar (void)
359 return maHorizontalScrollBar
;
365 /** This control shows an expansion bar for every control and in a
366 separate area below that expansion area it shows all controls each
367 with its title bar. When there is not enough space then show a
368 scroll bar in the control area.
370 void ScrollPanel::Rearrange (void)
372 Size
aRequiredSize (GetRequiredSize());
373 if (aRequiredSize
.Width()>0 && aRequiredSize
.Height()>0)
375 Size
aAvailableSize (SetupScrollBars (aRequiredSize
));
376 maScrollWindow
.SetPosSizePixel(
380 // Make the children at least as wide as the sub tool panel.
381 if (aRequiredSize
.Width() < aAvailableSize
.Width())
382 aRequiredSize
.Width() = aAvailableSize
.Width();
383 mnChildrenWidth
= -2*mnHorizontalBorder
;
384 if (maHorizontalScrollBar
.IsVisible())
385 mnChildrenWidth
+= aRequiredSize
.Width();
387 mnChildrenWidth
+= aAvailableSize
.Width();
389 sal_Int32
nChildrenHeight (LayoutChildren());
390 maVerticalScrollBar
.SetRangeMax (
391 nChildrenHeight
+ mnVerticalBorder
);
393 mbIsRearrangePending
= false;
400 Size
ScrollPanel::GetRequiredSize (void)
402 // First determine the width of the children. This is the maximum of
403 // the current window width and the individual minimum widths of the
405 int nChildrenWidth (GetSizePixel().Width());
406 unsigned int nCount
= mpControlContainer
->GetControlCount();
408 for (nIndex
=0; nIndex
<nCount
; nIndex
++)
410 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
411 int nMinimumWidth (pChild
->GetMinimumWidth());
412 if (nMinimumWidth
> nChildrenWidth
)
413 nChildrenWidth
= nMinimumWidth
;
416 // Determine the accumulated width of all children when scaled to the
418 nChildrenWidth
-= 2*mnHorizontalBorder
;
419 Size
aTotalSize (nChildrenWidth
,
420 2*mnVerticalBorder
+ (nCount
-1) * mnVerticalGap
);
421 for (nIndex
=0; nIndex
<nCount
; nIndex
++)
423 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
424 sal_Int32 nHeight
= pChild
->GetPreferredHeight(nChildrenWidth
);
425 aTotalSize
.Height() += nHeight
;
434 sal_Int32
ScrollPanel::LayoutChildren (void)
436 maStripeList
.clear();
438 Point
aPosition (maScrollOffset
);
439 aPosition
.X() += mnHorizontalBorder
;
440 maStripeList
.push_back( ::std::pair
<int,int>(
442 aPosition
.Y() + mnVerticalBorder
- 1));
443 aPosition
.Y() += mnVerticalBorder
;
445 // Place the controls one over the other.
446 unsigned int nCount (mpControlContainer
->GetControlCount());
447 for (unsigned int nIndex
=0; nIndex
<nCount
; nIndex
++)
451 maStripeList
.push_back( ::std::pair
<int,int>(
453 aPosition
.Y() + mnVerticalGap
- 1));
454 aPosition
.Y() += mnVerticalGap
;
456 TreeNode
* pChild
= mpControlContainer
->GetControl (nIndex
);
457 int nControlHeight
= pChild
->GetPreferredHeight(mnChildrenWidth
);
458 pChild
->GetWindow()->SetPosSizePixel(
460 Size(mnChildrenWidth
, nControlHeight
));
461 aPosition
.Y() += nControlHeight
;
464 // If the children do not cover their parent window completely
465 // (regarding the height) we put a filler below that is responsible for
466 // painting the remaining space.
467 int nWindowHeight
= maScrollWindow
.GetSizePixel().Height();
468 if (aPosition
.Y() < nWindowHeight
)
470 maScrollWindowFiller
.SetPosSizePixel (
472 Size(mnChildrenWidth
, nWindowHeight
-aPosition
.Y()));
473 maStripeList
.push_back( ::std::pair
<int,int>(
476 // maScrollWindowFiller.Show();
477 aPosition
.Y() = nWindowHeight
;
480 maScrollWindowFiller
.Hide();
482 aPosition
.Y() += mnVerticalBorder
;
483 mbIsLayoutPending
= false;
485 return aPosition
.Y()-maScrollOffset
.Y();
491 Size
ScrollPanel::SetupScrollBars (const Size
& rRequiredSize
)
493 Size
aWindowSize (GetSizePixel());
494 Size
aScrollBarSize (
495 maVerticalScrollBar
.GetSizePixel().Width(),
496 maHorizontalScrollBar
.GetSizePixel().Height());
497 Size
aRemainingSize (aWindowSize
);
499 // Determine which scroll bars have to be shown.
500 bool bShowHorizontal
= false;
501 if (rRequiredSize
.Width() > aWindowSize
.Width())
502 bShowHorizontal
= true;
503 bool bShowVertical
= false;
504 if (rRequiredSize
.Height() > aWindowSize
.Height())
505 bShowVertical
= true;
506 // Showing one scroll bar may reduce the available size so that the
507 // other one has to be shown as well.
508 if (bShowHorizontal
&& ! bShowVertical
)
510 if ((rRequiredSize
.Height() + aScrollBarSize
.Height())
511 > aWindowSize
.Height())
512 bShowVertical
= true;
514 else if (bShowVertical
&& ! bShowHorizontal
)
516 if (GetMinimumWidth() + aScrollBarSize
.Width() > aWindowSize
.Width())
517 bShowHorizontal
= true;
520 // Setup the scroll bars.
521 aRemainingSize
.Width()
522 = SetupVerticalScrollBar (bShowVertical
, rRequiredSize
.Height());
523 aRemainingSize
.Height()
524 = SetupHorizontalScrollBar (bShowHorizontal
, rRequiredSize
.Width());
527 if (bShowHorizontal
&& bShowVertical
)
529 maScrollBarFiller
.SetPosSizePixel (
530 Point(aWindowSize
.Width(), aWindowSize
.Height()),
532 maScrollBarFiller
.Show();
535 maScrollBarFiller
.Hide();
538 return aRemainingSize
;
544 sal_Int32
ScrollPanel::SetupVerticalScrollBar (bool bShow
, sal_Int32 nRange
)
546 Size
aScrollBarSize (
547 maVerticalScrollBar
.GetSizePixel().Width(),
548 maHorizontalScrollBar
.GetSizePixel().Height());
549 Size
aWindowSize (GetOutputSizePixel());
550 sal_Int32
nRemainingWidth (aWindowSize
.Width());
552 // Setup the verical scroll bar.
555 int nWidth
= aScrollBarSize
.Width();
556 int nHeight
= aWindowSize
.Height();
557 maVerticalScrollBar
.SetPosSizePixel(
558 Point(aWindowSize
.Width()-nWidth
,0),
559 Size(nWidth
, nHeight
));
560 maVerticalScrollBar
.Show();
562 // Set the scroll bar range and thumb size.
563 maVerticalScrollBar
.SetRangeMin (0);
564 maVerticalScrollBar
.SetRangeMax (
565 nRange
+ 2*mnVerticalBorder
);
566 maVerticalScrollBar
.SetVisibleSize (aWindowSize
.Height());
567 // Make page size approx. 10% of visible area.
568 maVerticalScrollBar
.SetLineSize (aWindowSize
.Height()/10);
569 // Make page size approx. 100% of visible area.
570 maVerticalScrollBar
.SetPageSize (aWindowSize
.Height());
571 // Make sure that thumb is inside the valid range.
572 maVerticalScrollBar
.SetThumbPos(-maScrollOffset
.Y());
573 long nMinPos
= maVerticalScrollBar
.GetRangeMin();
574 if (maVerticalScrollBar
.GetThumbPos() < nMinPos
)
575 maVerticalScrollBar
.SetThumbPos(nMinPos
);
576 long nMaxPos
= maVerticalScrollBar
.GetRangeMax()
577 - maVerticalScrollBar
.GetVisibleSize();
578 if (maVerticalScrollBar
.GetThumbPos() >= nMaxPos
)
579 maVerticalScrollBar
.SetThumbPos(nMaxPos
);
580 // Set offset to match thumb pos.
581 maScrollOffset
.Y() = -maVerticalScrollBar
.GetThumbPos();
583 nRemainingWidth
-= aScrollBarSize
.Width();
587 maVerticalScrollBar
.Hide();
588 maScrollOffset
.Y() = 0;
591 return nRemainingWidth
;
597 sal_Int32
ScrollPanel::SetupHorizontalScrollBar (bool bShow
, sal_Int32 nRange
)
599 Size
aScrollBarSize (
600 maVerticalScrollBar
.GetSizePixel().Width(),
601 maHorizontalScrollBar
.GetSizePixel().Height());
602 Size
aWindowSize (GetOutputSizePixel());
603 sal_Int32
nRemainingHeight (aWindowSize
.Height());
605 // Setup the horizontal scroll bar.
608 int nHeight
= aScrollBarSize
.Height();
609 int nWidth
= GetOutputSizePixel().Width();
610 maHorizontalScrollBar
.SetPosSizePixel(
611 Point(0, aWindowSize
.Height()-nHeight
),
612 Size(nWidth
,nHeight
));
613 maHorizontalScrollBar
.Show();
615 // Set the scroll bar range and thumb size.
616 maHorizontalScrollBar
.SetRangeMin (0);
617 maHorizontalScrollBar
.SetRangeMax (
618 nRange
+ 2*mnHorizontalBorder
);
619 maHorizontalScrollBar
.SetVisibleSize (aWindowSize
.Width());
620 // Make page size approx. 5% of visible area.
621 maHorizontalScrollBar
.SetLineSize (aWindowSize
.Width()/20+1);
622 // Make page size approx. 50% of visible area.
623 maHorizontalScrollBar
.SetPageSize (aWindowSize
.Width()/2+1);
624 // Make sure that thumb is inside the valid range.
625 maHorizontalScrollBar
.SetThumbPos(-maScrollOffset
.X());
626 long nMinPos
= maHorizontalScrollBar
.GetRangeMin();
627 if (maHorizontalScrollBar
.GetThumbPos() < nMinPos
)
628 maHorizontalScrollBar
.SetThumbPos(nMinPos
);
629 long nMaxPos
= maHorizontalScrollBar
.GetRangeMax()
630 - maHorizontalScrollBar
.GetVisibleSize();
631 if (maHorizontalScrollBar
.GetThumbPos() >= nMaxPos
)
632 maHorizontalScrollBar
.SetThumbPos(nMaxPos
);
633 // Set offset to match thumb pos.
634 maScrollOffset
.X() = -maHorizontalScrollBar
.GetThumbPos();
636 nRemainingHeight
-= aScrollBarSize
.Height();
640 maHorizontalScrollBar
.Hide();
641 maScrollOffset
.X() = 0;
644 return nRemainingHeight
;
648 IMPL_LINK(ScrollPanel
, ScrollBarHandler
, ScrollBar
*, EMPTYARG
)
650 maScrollOffset
.X() -= maHorizontalScrollBar
.GetDelta();
651 maScrollOffset
.Y() -= maVerticalScrollBar
.GetDelta();
653 // Scrolling is done by moving the child windows up or down.
654 mbIsLayoutPending
= true;
664 long ScrollPanel::Notify( NotifyEvent
& rNEvt
)
667 if( rNEvt
.GetType() == EVENT_COMMAND
)
669 // note: dynamic_cast is not possible as GetData() returns a void*
670 CommandEvent
* pCmdEvent
= reinterpret_cast< CommandEvent
* >(rNEvt
.GetData());
671 DBG_ASSERT( pCmdEvent
!=0 &&
672 ( pCmdEvent
->IsMouseEvent() == TRUE
||
673 pCmdEvent
->IsMouseEvent() == FALSE
),
674 "Invalid CommandEvent" );
676 switch (pCmdEvent
->GetCommand())
679 case COMMAND_STARTAUTOSCROLL
:
680 case COMMAND_AUTOSCROLL
:
682 nRet
= HandleScrollCommand (*pCmdEvent
, &maHorizontalScrollBar
, &maVerticalScrollBar
);
689 nRet
= ::Window::Notify( rNEvt
);
697 ::com::sun::star::uno::Reference
<
698 ::com::sun::star::accessibility::XAccessible
> ScrollPanel::CreateAccessibleObject (
699 const ::com::sun::star::uno::Reference
<
700 ::com::sun::star::accessibility::XAccessible
>& )
702 return new ::accessibility::AccessibleScrollPanel (
704 ::rtl::OUString::createFromAscii("Scroll Panel"),
705 ::rtl::OUString::createFromAscii("Scroll Panel"));
711 void ScrollPanel::MakeRectangleVisible (
712 Rectangle
& aRectangle
,
715 if (maVerticalScrollBar
.IsVisible() && aRectangle
.GetWidth()>0 && aRectangle
.GetHeight()>0)
717 const Rectangle
aRelativeBox (pWindow
->GetWindowExtentsRelative(&maScrollWindow
));
720 -maScrollOffset
.X() + aRelativeBox
.Left(),
721 -maScrollOffset
.Y() + aRelativeBox
.Top());
723 const int nVisibleHeight (maVerticalScrollBar
.GetVisibleSize());
724 const int nVisibleTop (maVerticalScrollBar
.GetThumbPos());
725 if (aRectangle
.Bottom() >= nVisibleTop
+nVisibleHeight
)
726 maVerticalScrollBar
.DoScroll(aRectangle
.Bottom() - nVisibleHeight
);
727 else if (aRectangle
.Top() < nVisibleTop
)
728 maVerticalScrollBar
.DoScroll(aRectangle
.Top());
735 IMPL_LINK(ScrollPanel
,WindowEventListener
,VclSimpleEvent
*,pEvent
)
737 VclWindowEvent
* pWindowEvent
= dynamic_cast<VclWindowEvent
*>(pEvent
);
738 if (pWindowEvent
!= NULL
)
740 switch (pWindowEvent
->GetId())
742 case VCLEVENT_WINDOW_KEYUP
:
743 case VCLEVENT_WINDOW_MOUSEBUTTONUP
:
745 // Make the currently selected item visible.
746 ValueSet
* pControl
= dynamic_cast<ValueSet
*>(pWindowEvent
->GetWindow());
747 if (pControl
!= NULL
)
749 // Get the bounding box of the currently selected item
750 // and enlarge this so that the selection frame is
752 Rectangle
aBox (pControl
->GetItemRect(pControl
->GetSelectItemId()));
756 MakeRectangleVisible(aBox
, pControl
);
761 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN
:
763 // Make the item under the mouse visible. We need this case
764 // for right clicks that open context menus. For these we
765 // only get the mouse down event. The following mouse up
766 // event is sent to the context menu.
767 ValueSet
* pControl
= dynamic_cast<ValueSet
*>(pWindowEvent
->GetWindow());
768 if (pControl
!= NULL
)
770 // Get the bounding box of the item at the mouse
771 // position and enlarge this so that the selection frame
772 // is inside as well.
773 MouseEvent
* pMouseEvent
774 = reinterpret_cast<MouseEvent
*>(pWindowEvent
->GetData());
775 if (pMouseEvent
!= NULL
)
777 Point
aPosition (pMouseEvent
->GetPosPixel());
778 Rectangle
aBox (pControl
->GetItemRect(pControl
->GetItemId(aPosition
)));
782 MakeRectangleVisible(aBox
, pControl
);
789 case VCLEVENT_WINDOW_GETFOCUS
:
791 // Move title bars into the visible area when they get the
792 // focus (::Window wise their enclosing TitledControl gets
794 TitledControl
* pTitledControl
= dynamic_cast<TitledControl
*>(pWindowEvent
->GetWindow());
795 if (pTitledControl
!=NULL
&& pTitledControl
->GetTitleBar()!=NULL
)
797 ::Window
* pTitleBarWindow
= pTitledControl
->GetTitleBar()->GetWindow();
798 Rectangle
aBox(pTitleBarWindow
->GetPosPixel(),pTitleBarWindow
->GetSizePixel());
799 MakeRectangleVisible(
806 case VCLEVENT_WINDOW_SHOW
:
807 case VCLEVENT_WINDOW_HIDE
:
808 case VCLEVENT_WINDOW_ACTIVATE
:
809 case VCLEVENT_WINDOW_RESIZE
:
810 // Rearrange the children of the scroll panel when one of
811 // the children changes its size or visibility.
822 } } // end of namespace ::sd::toolpanel